From Fedora Project Wiki
No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
#Check test file context {{command|ls -Z /tmp/test}}. Result should be <pre>unconfined_u:object_r:user_tmp_t:s0 /tmp/test</pre> | #Check test file context {{command|ls -Z /tmp/test}}. Result should be <pre>unconfined_u:object_r:user_tmp_t:s0 /tmp/test</pre> | ||
#Add new context for the test file {{command|semanage fcontext -a -t user_home_t "/tmp/test"}} | #Add new context for the test file {{command|semanage fcontext -a -t user_home_t "/tmp/test"}} | ||
#List local customisations {{command|semanage fcontext -l -C}} <pre>/tmp/test all files system_u:object_r:user_home_t:s0 | #List local customisations {{command|semanage fcontext -l -C}} <pre>/tmp/test all files system_u:object_r:user_home_t:s0</pre> | ||
</pre> | |||
#Apply new context {{command|restorecon /tmp/test}} | #Apply new context {{command|restorecon /tmp/test}} | ||
#Check that the context has changed {{command|ls -Z /tmp/test}} <pre>unconfined_u:object_r:user_home_t:s0 /tmp/test | #Check that the context has changed {{command|ls -Z /tmp/test}} <pre>unconfined_u:object_r:user_home_t:s0 /tmp/test</pre> | ||
</pre> | |||
#Remove custom context (revert to default) {{command|semanage fcontext -d -t user_home_t "/tmp/test"}} | #Remove custom context (revert to default) {{command|semanage fcontext -d -t user_home_t "/tmp/test"}} | ||
#Last action should result in the following warning: | #Last action should result in the following warning: | ||
<pre>restorecon: Warning no default label for /tmp/test | <pre>restorecon: Warning no default label for /tmp/test </pre> | ||
</pre> | |||
#Remove test file {{command|rm -rf /tmp/test}} | #Remove test file {{command|rm -rf /tmp/test}} | ||
|results= | |results= | ||
# All commands are executed successfully | # All commands are executed successfully | ||
# Context of the test file matches prescribed values | # Context of the test file matches prescribed values | ||
}} | }} | ||
[[Category:Package_policycoreutils_test_cases]] | [[Category:Package_policycoreutils_test_cases]] |
Revision as of 14:38, 1 August 2016
Description
This test case tests semanage basic functionalities (context addition/removal, listing).
Setup
Ensure that policycoreutils
package is installed.
How to test
- Create test file
touch /tmp/test
- Check test file context
ls -Z /tmp/test
. Result should beunconfined_u:object_r:user_tmp_t:s0 /tmp/test
- Add new context for the test file
semanage fcontext -a -t user_home_t "/tmp/test"
- List local customisations
semanage fcontext -l -C
/tmp/test all files system_u:object_r:user_home_t:s0
- Apply new context
restorecon /tmp/test
- Check that the context has changed
ls -Z /tmp/test
unconfined_u:object_r:user_home_t:s0 /tmp/test
- Remove custom context (revert to default)
semanage fcontext -d -t user_home_t "/tmp/test"
- Last action should result in the following warning:
restorecon: Warning no default label for /tmp/test
- Remove test file
rm -rf /tmp/test
Expected Results
- All commands are executed successfully
- Context of the test file matches prescribed values