From Fedora Project Wiki
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
|setup=Ensure that {{package|policycoreutils}} package is installed. | |setup=Ensure that {{package|policycoreutils}} package is installed. | ||
|actions= | |actions= | ||
<ol> | |||
<li>Create test file: <pre>#touch /tmp/test</pre> </li> | |||
<li>Check test file context: <pre>#ls -Z /tmp/test | |||
unconfined_u:object_r:user_tmp_t:s0 /tmp/test</pre> </li> | |||
<li>Add new context for the test file: <pre>#semanage fcontext -a -t user_home_t "/tmp/test"</pre></li> | |||
<li>List local customisations: <pre>#semanage fcontext -l -C | |||
/tmp/test all files system_u:object_r:user_home_t:s0</pre></li> | |||
<li>Apply new context: <pre>#restorecon /tmp/test</pre></li> | |||
<li>Check that the context has changed: <pre>#ls -Z /tmp/test | |||
unconfined_u:object_r:user_home_t:s0 /tmp/test</pre> </li> | |||
<li>Remove custom context (revert to default): <pre>#semanage fcontext -d -t user_home_t "/tmp/test" | |||
restorecon: Warning no default label for /tmp/test </pre></li> | |||
<li>Remove test file <pre>#rm -rf /tmp/test</pre></li> | |||
</ol> | |||
|results= | |results= | ||
# All commands are executed successfully | # All commands are executed successfully |
Revision as of 13:31, 4 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 unconfined_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" 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