|
From: Linda K. <lin...@hp...> - 2013-08-27 18:45:44
|
Looks better than the old code. :-)
-- ljk
On 08/21/13 12:24, Jiri Jaburek wrote:
> From: Miroslav Vadkerti <mva...@re...>
>
> This patch enhances the detection of clear screen after locking
> idle screen session.
>
> Signed-off-by: Miroslav Vadkerti <mva...@re...>
> ---
> .../trustedprograms/tests/test_screen_locking.bash | 2 +-
> .../trustedprograms/tests/tp_screen_functions.bash | 26 +++++++++++++---------
> 2 files changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/audit-test/trustedprograms/tests/test_screen_locking.bash b/audit-test/trustedprograms/tests/test_screen_locking.bash
> index 5e86dc7..ba4c69d 100755
> --- a/audit-test/trustedprograms/tests/test_screen_locking.bash
> +++ b/audit-test/trustedprograms/tests/test_screen_locking.bash
> @@ -85,7 +85,7 @@ screen_check_badpass $TEST_USER $TEST_USER_PASSWD 2 || exit_fail \
> # check if
> # + escape sequence for clearing the screen sent if screen locked
> # + kernel boot options contain "no-scroll" and "fbcon=scrollback:0"
> -screen_check_clear $TEST_USER $TEST_USER_PASSWD 2 || exit_fail \
> +screen_check_clear $TEST_USER $TEST_USER_PASSWD 5 || exit_fail \
> "screen clear before locking failed ($?)"
>
> # checks if
> diff --git a/audit-test/trustedprograms/tests/tp_screen_functions.bash b/audit-test/trustedprograms/tests/tp_screen_functions.bash
> index 853e1d6..c28f363 100644
> --- a/audit-test/trustedprograms/tests/tp_screen_functions.bash
> +++ b/audit-test/trustedprograms/tests/tp_screen_functions.bash
> @@ -182,13 +182,13 @@ function screen_check_clear {
> # To check you terminal type use the command
> # echo $TERM
> #
> + prepend_cleanup "rm -f $EXPSCRIPT"
> cat > $EXPSCRIPT << EOT
> set timeout $(($3+1))
> spawn screen $4
> -expect {
> - -re ".*\\x1b\\x5c\\x5b\\x48\\x1b\\x5c\\x5b\\x4a.*" { send -- $2\r }
> - -re ".*\\x1b\\x5c\\x5b\\x48\\x1b\\x5c\\x5b\\x32\\x4a.*" { send -- $2\r }
> - default { exit 1 }
> +expect {$1} {
> + sleep 4
> + send { send -- $2\r }
> }
> expect {
> {$1} { send -- exit\r }
> @@ -200,16 +200,20 @@ EOT
>
> # run the expect script as user
> chown ${1}:$1 $EXPSCRIPT
> - /bin/su - -c "expect $EXPSCRIPT" $1
> - RET=$?
> + EXPOUT=$(mktemp)
> + prepend_cleanup "rm -f $EXPOUT"
> + /bin/su - -c "expect $EXPSCRIPT" $1 &> $EXPOUT
> + hexdump -C $EXPOUT
> + # count the number of lines with clear screen
> + # screen should clear the screen 2 times after running
> + # and once after locking the screen
> + CLRCNT=$(cat $EXPOUT | xxd -p | tr -d '\n' | grep -o "$(clear | xxd -p)" | wc -l)
> + [ "$CLRCNT" -eq 3 ] && RET=0 || RET=1
>
> # check if kernel cmdline contains required options for
> # disabling framebuffer scrolling
> - grep "no-scroll" /proc/cmdline || RET=4
> - grep "fbcon=scrollback:0" /proc/cmdline || RET=5
> -
> - # remove the expect script
> - rm -f $EXPSCRIPT
> + grep "no-scroll" /proc/cmdline || RET=2
> + grep "fbcon=scrollback:0" /proc/cmdline || RET=3
>
> return $RET
> }
>
|