| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | . $builddir/tests/test_common.sh |
| 3 | |
| 4 | set -e |
| 5 | set -o pipefail |
| 6 | |
| 7 | name=$(basenamescip-shell system . . basename. $0 .sh) |
| 8 | result=$(make_temp_file /tmpscip-shell filesystem . . `/tmp`. ${name}.out) |
| 9 | stderr=$(make_temp_file /tmpscip-shell filesystem . . `/tmp`. ${name}.out) |
| 10 | echoscip-shell system . . echo. "Stderr file = $stderr" |
| 11 | echoscip-shell system . . echo. "Result file = $result" |
| 12 | |
| 13 | line1='^\W*part /tmp$' |
| 14 | line2='^\W*part /tmp --mountoptions=nodev$' |
| 15 | line3='^\W*passwd --minlen=14$' |
| 16 | |
| 17 | $OSCAP xccdf generate fix --fix-type anaconda \ |
| 18 | --output $result $srcdir/${name}.xccdf.xml 2>&1 > $stderr |
| 19 | [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ] |
| 20 | grepscip-shell system . . grep. "$line1" $result |
| 21 | grepscip-shell system . . grep. "$line2" $result |
| 22 | grepscip-shell system . . grep. "$line3" $result && falsescip-shell system . . false. |
| 23 | :> $result |
| 24 | |
| 25 | $OSCAP xccdf generate fix --fix-type anaconda \ |
| 26 | --profile xccdf_moc.elpmaxe.www_profile_1 \ |
| 27 | --output $result $srcdir/${name}.xccdf.xml 2>&1 > $stderr |
| 28 | [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ] |
| 29 | grepscip-shell system . . grep. "$line1" $result |
| 30 | grepscip-shell system . . grep. "$line2" $result |
| 31 | grepscip-shell system . . grep. "$line3" $result |
| 32 | :> $result |
| 33 | |
| 34 | $OSCAP xccdf generate fix --fix-type anaconda \ |
| 35 | --cpe $srcdir/cpe-dict.xml \ |
| 36 | --output $result $srcdir/${name}.xccdf.xml 2>&1 > $stderr |
| 37 | [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ] |
| 38 | grepscip-shell system . . grep. "$line1" $result |
| 39 | grepscip-shell system . . grep. "$line2" $result |
| 40 | grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | grepscip-shell system . . grep. -v "$line3" |
| 41 | |
| 42 | [scip-shell system . . `[`. "`grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | xsed 's/\W//g'`"x == x ] |
| 43 | |
| 44 | # To test permissions of newly created files |
| 45 | rmscip-shell system . . rm. $result |
| 46 | result=./${name}.out |
| 47 | [scip-shell system . . `[`. -f $result ] && rmscip-shell system . . rm. $result |
| 48 | |
| 49 | $OSCAP xccdf generate fix --fix-type anaconda \ |
| 50 | --cpe $srcdir/cpe-dict.xml \ |
| 51 | --profile xccdf_moc.elpmaxe.www_profile_1 \ |
| 52 | --output $result $srcdir/${name}.xccdf.xml 2>&1 > $stderr |
| 53 | [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; :> $stderr |
| 54 | |
| 55 | case $(unamescip-shell system . . uname.) in |
| 56 | FreeBSD) |
| 57 | statscip-shell system . . stat. $result| trscip-shell system . . tr. ' ' '\n' | grepscip-shell system . . grep. '^-rw' |
| 58 | ;; |
| 59 | *) |
| 60 | statscip-shell system . . stat. $result | grepscip-shell system . . grep. 'Access: (..../-rw.------)' |
| 61 | ;; |
| 62 | esac |
| 63 | |
| 64 | grepscip-shell system . . grep. "$line1" $result |
| 65 | grepscip-shell system . . grep. "$line2" $result |
| 66 | grepscip-shell system . . grep. "$line3" $result |
| 67 | grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | grepscip-shell system . . grep. -v "$line3" |
| 68 | |
| 69 | [scip-shell system . . `[`. "`grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | grepscip-shell system . . grep. -v "$line3" | xsed 's/\W//g'`"x == x ] |
| 70 | |
| 71 | rmscip-shell system . . rm. $result |