From Fedora Project Wiki

Revision as of 09:45, 18 December 2017 by Lvrabec (talk | contribs) (Added "-v" parameter in 5. step of testing for restorecon.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

This test case tests semanage basic functionalities (context addition/removal, listing).

Setup

Ensure that Package-x-generic-16.pngpolicycoreutils package is installed.

How to test

  1. Create test file:
    #touch /tmp/test
  2. Check test file context:
    #ls -Z /tmp/test
    unconfined_u:object_r:user_tmp_t:s0 /tmp/test
  3. Add new context for the test file:
    #semanage fcontext -a -t user_home_t "/tmp/test"
  4. List local customisations:
    #semanage fcontext -l -C
    /tmp/test    all files    system_u:object_r:user_home_t:s0
  5. Apply new context:
    #restorecon -v /tmp/test
  6. Check that the context has changed:
    #ls -Z /tmp/test
    unconfined_u:object_r:user_home_t:s0 /tmp/test
  7. Remove custom context (revert to default):
    #semanage fcontext -d -t user_home_t "/tmp/test"
    restorecon:  Warning no default label for /tmp/test 
  8. Remove test file
    #rm -rf /tmp/test

Expected Results

  1. All commands are executed successfully
  2. Context of the test file matches prescribed values