#15 fix hidden failure in policycoreutils/restorecon
Closed 5 years ago by plautrba. Opened 5 years ago by janzarsky.
https://github.com/janzarsky/selinux-tests jzarsky-restorecon  into  master

enable policycoreutils/restorecon
Jan Zarsky • 5 years ago  
check if mcstrans is present before stopping it
Jan Zarsky • 5 years ago  
fix hidden failure in check_contexts
Jan Zarsky • 5 years ago  
policycoreutils/restorecon/main.fmf
file modified
+1 -1
@@ -1,2 +1,2 @@

  path: /policycoreutils/restorecon

- component: disabled

+ tier: 1

policycoreutils/restorecon/runtest.sh
file modified
+17 -6
@@ -35,7 +35,11 @@

  rlJournalStart

      rlPhaseStartSetup

          rlAssertRpm ${PACKAGE}

-         rlServiceStop mcstrans mcstransd

+         if which mcstrans; then

+             rlServiceStop mcstrans

+         elif which mcstransd; then

+             rlServiceStop mcstransd

+         fi

          rlRun "rpm -qf `which restorecon` | grep ${PACKAGE}"

          rlRun "setenforce 1"

          rlRun "sestatus"
@@ -111,10 +115,13 @@

  

          # Check that files matching with $2 in dir $1 have context $3

          function check_contexts {

-             COMMAND="find $1 -name '$2'"

-             for ITEM in `eval $COMMAND`; do

-                 rlRun "ls -ladZ $ITEM | grep :$3";

+             rlRun "find $1 -name '$2' >files"

+             rlRun "[ $(cat files | wc -l) -gt 0 ]"

+ 

+             for f in $files; do

+                 rlRun "ls -ladZ $f | grep :$3"

              done

+             rlRun "rm files"

          }

  

          # Create the testing dirs and files
@@ -184,7 +191,7 @@

          check_initial_contexts 'incorrect1.dir'

          check_initial_contexts 'correct.dir'

          check_initial_contexts 'customizable.dir'

-         check_contexts 'incorrect2' '*' 'correct_t'

+         check_contexts 'incorrect2.dir' '*' 'correct_t'

          rlRun "ls -ladZ customizable.file | grep customizable_t"

          rlRun "ls -ladZ incorrect.file | grep :correct_t"

  
@@ -360,7 +367,11 @@

      fi

  

      rlPhaseStartCleanup

-         rlServiceRestore mcstrans mcstransd

+         if which mcstrans; then

+             rlServiceRestore mcstrans

+         elif which mcstransd; then

+             rlServiceRestore mcstransd

+         fi

      rlPhaseEnd

      rlJournalPrintText

  rlJournalEnd

no initial comment

check_contexts was checking contexts in a loop and there was no warning when there were no files to check (because of invalid parameter). Fix this by counting the files to be checked. Fix also one invalid call to check_contexts.

Check if the mcstrans or mcstransd binaries are present. This prevents unnecessary warnings.

1 new commit added

  • enable policycoreutils/restorecon
5 years ago

I added new commit that enables the TC.

3 new commits added

  • enable policycoreutils/restorecon
  • check if mcstrans is present before stopping it
  • fix hidden failure in check_contexts
5 years ago

Add also 'tier: 1' to the main.fmf file.

Pull-Request has been closed by plautrba

5 years ago