* [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup
@ 2014-12-23 9:33 Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 02/12] smack_file_access.sh: Cleanup Zeng Linggang
` (10 more replies)
0 siblings, 11 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* On some systems 'smackfs' mounts aren't listed in the output from 'df',
so we switch to the '/proc/mounts' instead.
* Use 'tst_brkm'.
* Use '$()' instead of '``'.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
testcases/kernel/security/smack/smack_common.sh | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/testcases/kernel/security/smack/smack_common.sh b/testcases/kernel/security/smack/smack_common.sh
index 5d7f112..d4165d1 100755
--- a/testcases/kernel/security/smack/smack_common.sh
+++ b/testcases/kernel/security/smack/smack_common.sh
@@ -27,20 +27,20 @@
smackfsdir=${smackfsdir:=/smack}
-check_mounted() {
- if ! expr "$smackfsdir" : "$(df -P | awk "\$NF == \"$smackfsdir\""'{ print $NF }')"; then
- echo "smackfs not mounted at $smackfsdir"
- exit 1
+check_mounted()
+{
+ grep -q $smackfsdir /proc/mounts
+ if [ $? -ne 0 ]; then
+ tst_brkm TCONF "smackfs not mounted at \"$smackfsdir\""
fi
}
-check_onlycap() {
- onlycap=`cat "$smackfsdir/onlycap" 2>/dev/null`
- if [ "$onlycap" != "" ]; then
- cat <<EOM
-The smack label reported for $smackfsdir/onlycap is "$onlycap", not the expected "".
-EOM
- exit 1
+check_onlycap()
+{
+ onlycap=$(cat "$smackfsdir/onlycap" 2>/dev/null)
+ if [ -n "$onlycap" ]; then
+ tst_brkm TCONF "\"$smackfsdir/onlycap\" is \"$onlycap\", not" \
+ "the expected \"\"."
fi
}
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 02/12] smack_file_access.sh: Cleanup
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
2015-01-19 15:51 ` Cyril Hrubis
2014-12-23 9:33 ` [LTP] [PATCH v2 03/12] smack_set_ambient.sh: Cleanup Zeng Linggang
` (9 subsequent siblings)
10 siblings, 1 reply; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* Use 'test.sh' script and use 'tst_*'.
* Add 'TCID' and 'TST_TOTAL' global variables.
* Use '.' instead of 'source'.
* Use 'tst_tmpdir' and 'tst_rmdir'.
* Use '$()' instead of '``'.
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
.../kernel/security/smack/smack_file_access.sh | 128 +++++++++------------
1 file changed, 52 insertions(+), 76 deletions(-)
diff --git a/testcases/kernel/security/smack/smack_file_access.sh b/testcases/kernel/security/smack/smack_file_access.sh
index 61db065..a2d09c0 100755
--- a/testcases/kernel/security/smack/smack_file_access.sh
+++ b/testcases/kernel/security/smack/smack_file_access.sh
@@ -14,106 +14,82 @@
# 1 2 3 4 5 6
# 123456789012345678901234567890123456789012345678901234567890123456789
-source smack_common.sh
+export TCID=smack_file_access
+export TST_TOTAL=1
-RuleA="TheOne TheOther r---"
-RuleB="TheOne TheOther rw--"
+. test.sh
+
+. smack_common.sh
+
+cleanup()
+{
+ tst_rmdir
+}
+
+rule_a="TheOne TheOther r---"
+rule_b="TheOne TheOther rw--"
-Where="./testdir"
-What="testfile"
-TestFile="$Where/$What"
CAT=/bin/cat
+testfile="testfile"
-if [ ! -d "$Where" ]; then
- if [ -e "$Where" ]; then
- echo "Test directory \"$Where\" exists but is not a directory."
- exit 1
- fi
- mkdir -m 777 "$Where"
- if [ ! -d "$Where" ]; then
- echo "Test directory \"$Where\" can not be created."
- exit 1
- fi
-fi
+tst_tmpdir
+TST_CLEANUP=cleanup
+
+chmod 777 $(pwd)
-if [ ! -f "$TestFile" ]; then
- if [ -e "$TestFile" ]; then
- echo "Test file \"$TestFile\" exists but is not a file."
- rm -rf "$Where"
- exit 1
- fi
- ./notroot /bin/sh -c "echo InitialData 2>/dev/null > $TestFile"
- if [ ! -d "$TestFile" ]; then
- echo "Test file \"$TestFile\" can not be created."
- rm -rf "$Where"
- exit 1
- fi
+notroot /bin/sh -c "echo InitialData 2>/tmp/smack_fail.log > $testfile"
+if [ ! -f "$testfile" ]; then
+ tst_brkm TFAIL "Test file \"$testfile\" can not be created."
fi
-setfattr --name=security.SMACK64 --value=TheOther "$TestFile"
-SetTo=`getfattr --only-values -n security.SMACK64 -e text $TestFile`
-SetTo=`echo $SetTo`
+setfattr --name=security.SMACK64 --value=TheOther "$testfile"
+setto=$(getfattr --only-values -n security.SMACK64 -e text $testfile)
-if [ "TheOther" != "$SetTo" ]; then
- echo "Test file \"$TestFile\" labeled \"$SetTo\" incorrectly."
- rm -rf "$Where"
- exit 1
+if [ "TheOther" != "$setto" ]; then
+ tst_brkm TFAIL "Test file \"$testfile\" labeled \"$setto\" incorrectly."
fi
-OldRule=`grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther '`
+old_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
-echo -n "$RuleA" > "$smackfsdir/load"
-NewRule=`grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther '`
-if [ "$NewRule" = "" ]; then
- echo "Rule did not get set."
- rm -rf "$Where"
- exit 1
+echo -n "$rule_a" > "$smackfsdir/load"
+new_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
+if [ "$new_rule" = "" ]; then
+ tst_brkm TFAIL "Rule did not get set."
fi
-Mode=`echo $NewRule | sed -e 's/.* //'`
-if [ "$Mode" != "r" ]; then
- echo "Rule \"$NewRule\" is not set correctly."
- rm -rf "$Where"
- exit 1
+mode=$(echo $new_rule | sed -e 's/.* //')
+if [ "$mode" != "r" ]; then
+ tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
fi
-OldProc=`cat /proc/self/attr/current 2>/dev/null`
-
echo TheOne 2>/dev/null > /proc/self/attr/current
-GotRead=`./notroot $CAT "$TestFile"`
+got_read=$(smack_notroot $CAT "$testfile")
-if [ "$GotRead" != "InitialData" ]; then
- echo "Read failed for \"$TestFile\" labeled \"TheOther\"."
- rm -rf "$Where"
- exit 1
+if [ "$got_read" != "InitialData" ]; then
+ tst_brkm TFAIL "Read failed for \"$testfile\" labeled \"TheOther\"."
fi
echo NotTheOne 2>/dev/null > /proc/self/attr/current
-GotRead=`./notroot $CAT "$TestFile"`
+got_read=$(smack_notroot $CAT "$testfile" 2> /dev/null)
-if [ "$GotRead" = "InitialData" ]; then
- echo "Read should have failed for \"$TestFile\" labeled \"TheOther\"."
- rm -rf "$Where"
- exit 1
+if [ "$got_read" = "InitialData" ]; then
+ tst_brkm TFAIL "Read should have failed for \"$testfile\" labeled" \
+ "\"TheOther\"."
fi
-echo -n "$RuleB" 2>/dev/null > "$smackfsdir/load"
-NewRule=`grep "^TheOne" $smackfsdir/load 2>/dev/null | grep ' TheOther '`
-if [ "$NewRule" = "" ]; then
- echo "Rule did not get set."
- rm -rf "$Where"
- exit 1
+echo -n "$rule_b" 2>/dev/null > "$smackfsdir/load"
+new_rule=$(grep "^TheOne" $smackfsdir/load 2>/dev/null | grep ' TheOther ')
+if [ "$new_rule" = "" ]; then
+ tst_brkm TFAIL "Rule did not get set."
fi
-Mode=`echo $NewRule | sed -e 's/.* //'`
-if [ "$Mode" != "rw" ]; then
- echo "Rule \"$NewRule\" is not set correctly."
- rm -rf "$Where"
- exit 1
+mode=$(echo $new_rule | sed -e 's/.* //')
+if [ "$mode" != "rw" ]; then
+ tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
fi
-if [ "$OldRule" != "$NewRule" ]; then
- cat <<EOM
-Notice: Test access rule changed from "$OldRule" to "$NewRule".
-EOM
+if [ "$old_rule" != "$new_rule" ]; then
+ tst_resm TINFO "Notice: Test access rule changed from \"$old_rule\"" \
+ "to \"$new_rule\"."
fi
-rm -rf "$Where"
+tst_resm TPASS "Test \"$TCID\" success."
+tst_exit
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 03/12] smack_set_ambient.sh: Cleanup
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 02/12] smack_file_access.sh: Cleanup Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 04/12] smack_set_cipso.sh: Cleanup Zeng Linggang
` (8 subsequent siblings)
10 siblings, 0 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* Use 'test.sh' script and use 'tst_*'.
* Add 'TCID' and 'TST_TOTAL' global variables.
* Use '.' instead of 'source'.
* Use '$()' instead of '``'.
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
.../kernel/security/smack/smack_set_ambient.sh | 39 ++++++++++++----------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/testcases/kernel/security/smack/smack_set_ambient.sh b/testcases/kernel/security/smack/smack_set_ambient.sh
index fcfdbc5..c100b44 100755
--- a/testcases/kernel/security/smack/smack_set_ambient.sh
+++ b/testcases/kernel/security/smack/smack_set_ambient.sh
@@ -10,28 +10,31 @@
# CAP_MAC_ADMIN
#
-source smack_common.sh
+export TCID=smack_set_ambient
+export TST_TOTAL=1
-NotTheFloorLabel="XYZZY"
-StartLabel=`cat "$smackfsdir/ambient" 2>/dev/null`
+. test.sh
-echo "$NotTheFloorLabel" 2>/dev/null > "$smackfsdir/ambient"
+. smack_common.sh
-label=`cat "$smackfsdir/ambient" 2>/dev/null`
-if [ "$label" != "$NotTheFloorLabel" ]; then
- cat <<EOM
-The smack label reported for the current process is "$label", not the expected
-"$NotTheFloorLabel".
-EOM
- exit 1
+not_floor_label="XYZZY"
+start_label=$(cat "$smackfsdir/ambient" 2>/dev/null)
+
+echo "$not_floor_label" 2>/dev/null > "$smackfsdir/ambient"
+
+label=$(cat "$smackfsdir/ambient" 2>/dev/null)
+if [ "$label" != "$not_floor_label" ]; then
+ tst_brkm TFAIL "The smack label reported for the current process is" \
+ "\"$label\", not the expected \"$not_floor_label\"."
fi
-echo "$StartLabel" 2>/dev/null > "$smackfsdir/ambient"
+echo "$start_label" 2>/dev/null > "$smackfsdir/ambient"
-label=`cat "$smackfsdir/ambient" 2>/dev/null`
-if [ "$label" != "$StartLabel" ]; then
- cat <<EOM
-The smack label reported for the current process is "$label", not the expected "$StartLabel".
-EOM
- exit 1
+label=$(cat "$smackfsdir/ambient" 2>/dev/null)
+if [ "$label" != "$start_label" ]; then
+ tst_brkm TFAIL "The smack label reported for the current process is" \
+ "\"$label\", not the expected \"$start_label\"."
fi
+
+tst_resm TPASS "Test \"$TCID\" success."
+tst_exit
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 04/12] smack_set_cipso.sh: Cleanup
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 02/12] smack_file_access.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 03/12] smack_set_ambient.sh: Cleanup Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 05/12] smack_set_current.sh: Cleanup Zeng Linggang
` (7 subsequent siblings)
10 siblings, 0 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* Use 'test.sh' script and use 'tst_*'.
* Add 'TCID' and 'TST_TOTAL' global variables.
* Use '.' instead of 'source'.
* Use '$()' instead of '``'.
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
testcases/kernel/security/smack/smack_set_cipso.sh | 73 +++++++++++-----------
1 file changed, 37 insertions(+), 36 deletions(-)
diff --git a/testcases/kernel/security/smack/smack_set_cipso.sh b/testcases/kernel/security/smack/smack_set_cipso.sh
index 1c7321f..c0a8a79 100755
--- a/testcases/kernel/security/smack/smack_set_cipso.sh
+++ b/testcases/kernel/security/smack/smack_set_cipso.sh
@@ -14,52 +14,53 @@
# 1 2 llllCCCCccccCCCCcccc 5 6
# 123456789012345678901234567890123456789012345678901234567890123456789
-source smack_common.sh
+export TCID=smack_set_cipso
+export TST_TOTAL=1
-RuleA="TheOne 2 0 "
-RuleB="TheOne 3 1 55 "
-RuleC="TheOne 4 2 17 33 "
+. test.sh
-OldRule=`grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null`
+. smack_common.sh
-echo -n "$RuleA" 2>/dev/null > "$smackfsdir/cipso"
-NewRule=`grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null`
-if [ "$NewRule" = "" ]; then
- echo "Rule did not get set."
- exit 1
+rule_a="TheOne 2 0 "
+rule_b="TheOne 3 1 55 "
+rule_c="TheOne 4 2 17 33 "
+
+old_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null)
+
+echo -n "$rule_a" 2>/dev/null > "$smackfsdir/cipso"
+new_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null)
+if [ "$new_rule" = "" ]; then
+ tst_brkm TFAIL "Rule did not get set."
fi
-Right=`echo "$NewRule" | grep ' 2'`
-if [ "$Right" = "" ]; then
- echo "Rule \"$NewRule\" is not set correctly."
- exit 1
+right=$(echo "$new_rule" | grep ' 2')
+if [ "$right" = "" ]; then
+ tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
fi
-echo -n "$RuleB" 2>/dev/null > "$smackfsdir/cipso"
-NewRule=`grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null`
-if [ "$NewRule" = "" ]; then
- echo "Rule did not get set."
- exit 1
+echo -n "$rule_b" 2>/dev/null > "$smackfsdir/cipso"
+new_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null)
+if [ "$new_rule" = "" ]; then
+ tst_brkm TFAIL "Rule did not get set."
fi
-Right=`echo $NewRule | grep '/55'`
-if [ "$Right" = "" ]; then
- echo "Rule \"$NewRule\" is not set correctly."
- exit 1
+right=$(echo $new_rule | grep '/55')
+if [ "$right" = "" ]; then
+ tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
fi
-echo -n "$RuleC" 2>/dev/null > "$smackfsdir/cipso"
-NewRule=`grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null`
-if [ "$NewRule" = "" ]; then
- echo "Rule did not get set."
- exit 1
+echo -n "$rule_c" 2>/dev/null > "$smackfsdir/cipso"
+new_rule=$(grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null)
+if [ "$new_rule" = "" ]; then
+ tst_brkm TFAIL "Rule did not get set."
fi
-Right=`echo "$NewRule" | grep '/17,33'`
-if [ "$Right" = "" ]; then
- echo "Rule \"$NewRule\" is not set correctly."
- exit 1
+right=$(echo "$new_rule" | grep '/17,33')
+if [ "$right" = "" ]; then
+ tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
fi
-if [ "$OldRule" != "$NewRule" ]; then
- cat <<EOM
-Notice: Test access rule changed from "$OldRule" to "$NewRule".
-EOM
+if [ "$old_rule" != "$new_rule" ]; then
+ tst_resm TINFO "Notice: Test access rule changed from \"$old_rule\"" \
+ "to \"$new_rule\"."
fi
+
+tst_resm TPASS "Test \"$TCID\" success."
+tst_exit
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 05/12] smack_set_current.sh: Cleanup
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
` (2 preceding siblings ...)
2014-12-23 9:33 ` [LTP] [PATCH v2 04/12] smack_set_cipso.sh: Cleanup Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 06/12] smack_set_direct.sh: Cleanup Zeng Linggang
` (6 subsequent siblings)
10 siblings, 0 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* Use 'test.sh' script and use 'tst_*'.
* Add 'TCID' and 'TST_TOTAL' global variables.
* Use '.' instead of 'source'.
* Use '$()' instead of '``'.
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
.../kernel/security/smack/smack_set_current.sh | 40 ++++++++++++----------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/testcases/kernel/security/smack/smack_set_current.sh b/testcases/kernel/security/smack/smack_set_current.sh
index 28a1b1b..4e52c89 100755
--- a/testcases/kernel/security/smack/smack_set_current.sh
+++ b/testcases/kernel/security/smack/smack_set_current.sh
@@ -11,29 +11,31 @@
# /smack/onlycap unset
#
-source smack_common.sh
+export TCID=smack_set_current
+export TST_TOTAL=1
-NotTheFloorLabel="XYZZY"
-StartLabel=`cat /proc/self/attr/current 2>/dev/null`
+. test.sh
-echo "$NotTheFloorLabel" 2>/dev/null > /proc/self/attr/current
+. smack_common.sh
-label=`cat /proc/self/attr/current 2>/dev/null`
-if [ "$label" != "$NotTheFloorLabel" ]; then
- cat <<EOM
-The smack label reported for the current process is "$label",
-not the expected "$NotTheFloorLabel".
-EOM
- exit 1
+not_floor_label="XYZZY"
+start_label=$(cat /proc/self/attr/current 2>/dev/null)
+
+echo "$not_floor_label" 2>/dev/null > /proc/self/attr/current
+
+label=$(cat /proc/self/attr/current 2>/dev/null)
+if [ "$label" != "$not_floor_label" ]; then
+ tst_brkm TFAIL "The smack label reported for the current process is" \
+ "\"$label\", not the expected \"$not_floor_label\"."
fi
-echo "$StartLabel" 2>/dev/null > /proc/self/attr/current
+echo "$start_label" 2>/dev/null > /proc/self/attr/current
-label=`cat /proc/self/attr/current > /dev/null`
-if [ "$label" != "$StartLabel" ]; then
- cat <<EOM
-The smack label reported for the current process is "$label",
-not the expected "$StartLabel".
-EOM
- exit 1
+label=$(cat /proc/self/attr/current 2> /dev/null)
+if [ "$label" != "$start_label" ]; then
+ tst_brkm TFAIL "The smack label reported for the current process is" \
+ "\"$label\", not the expected \"$start_label\"."
fi
+
+tst_resm TPASS "Test \"$TCID\" success."
+tst_exit
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 06/12] smack_set_direct.sh: Cleanup
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
` (3 preceding siblings ...)
2014-12-23 9:33 ` [LTP] [PATCH v2 05/12] smack_set_current.sh: Cleanup Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 07/12] smack_set_doi.sh: Cleanup Zeng Linggang
` (5 subsequent siblings)
10 siblings, 0 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* Use 'test.sh' script and use 'tst_*'.
* Add 'TCID' and 'TST_TOTAL' global variables.
* Use '.' instead of 'source'.
* Use '$()' instead of '``'.
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
.../kernel/security/smack/smack_set_direct.sh | 40 ++++++++++++----------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/testcases/kernel/security/smack/smack_set_direct.sh b/testcases/kernel/security/smack/smack_set_direct.sh
index 84135f5..9d27653 100755
--- a/testcases/kernel/security/smack/smack_set_direct.sh
+++ b/testcases/kernel/security/smack/smack_set_direct.sh
@@ -10,29 +10,31 @@
# CAP_MAC_ADMIN
#
-source smack_common.sh
+export TCID=smack_set_direct
+export TST_TOTAL=1
-NotTheStartValue="17"
-StartValue=`cat "$smackfsdir/direct" 2>/dev/null`
+. test.sh
-echo "$NotTheStartValue" 2>/dev/null > "$smackfsdir/direct"
+. smack_common.sh
-DirectValue=`cat "$smackfsdir/direct" 2>/dev/null`
-if [ "$DirectValue" != "$NotTheStartValue" ]; then
- cat <<EOM
-The CIPSO direct level reported is "$DirectValue",
-not the expected "$NotTheStartValue".
-EOM
- exit 1
+not_start_value="17"
+start_value=$(cat "$smackfsdir/direct" 2>/dev/null)
+
+echo "$not_start_value" 2>/dev/null > "$smackfsdir/direct"
+
+direct_value=$(cat "$smackfsdir/direct" 2>/dev/null)
+if [ "$direct_value" != "$not_start_value" ]; then
+ tst_brkm TFAIL "The CIPSO direct level reported is \"$direct_value\"," \
+ "not the expected \"$not_start_value\"."
fi
-echo "$StartValue" 2>/dev/null> "$smackfsdir/direct"
+echo "$start_value" 2>/dev/null> "$smackfsdir/direct"
-DirectValue=`cat "$smackfsdir/direct" 2>/dev/null`
-if [ "$DirectValue" != "$StartValue" ]; then
- cat <<EOM
-The CIPSO direct level reported is "$DirectValue",
-not the expected "$StartValue".
-EOM
- exit 1
+direct_value=$(cat "$smackfsdir/direct" 2>/dev/null)
+if [ "$direct_value" != "$start_value" ]; then
+ tst_brkm TFAIL "The CIPSO direct level reported is \"$direct_value\"," \
+ "not the expected \"$start_value\"."
fi
+
+tst_resm TPASS "Test \"$TCID\" success."
+tst_exit
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 07/12] smack_set_doi.sh: Cleanup
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
` (4 preceding siblings ...)
2014-12-23 9:33 ` [LTP] [PATCH v2 06/12] smack_set_direct.sh: Cleanup Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 08/12] smack_set_load.sh: Cleanup Zeng Linggang
` (4 subsequent siblings)
10 siblings, 0 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* Use 'test.sh' script and use 'tst_*'.
* Add 'TCID' and 'TST_TOTAL' global variables.
* Use '.' instead of 'source'.
* Use '$()' instead of '``'.
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
testcases/kernel/security/smack/smack_set_doi.sh | 40 ++++++++++++------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/testcases/kernel/security/smack/smack_set_doi.sh b/testcases/kernel/security/smack/smack_set_doi.sh
index 8aca7d0..c6636e1 100755
--- a/testcases/kernel/security/smack/smack_set_doi.sh
+++ b/testcases/kernel/security/smack/smack_set_doi.sh
@@ -10,31 +10,31 @@
# CAP_MAC_ADMIN
#
-source smack_common.sh
+export TCID=smack_set_doi
+export TST_TOTAL=1
-NotTheStartValue="17"
-StartValue=`cat "$smackfsdir/doi" 2>/dev/null`
+. test.sh
-echo "$NotTheStartValue" 2>/dev/null > "$smackfsdir/doi"
+. smack_common.sh
-DirectValue=`cat "$smackfsdir/doi" 2>/dev/null`
-if [ "$DirectValue" != "$NotTheStartValue" ]; then
- cat <<EOM
-The CIPSO doi reported is "$DirectValue",
-not the expected "$NotTheStartValue".
-EOM
- exit 1
+not_start_value="17"
+start_value=$(cat "$smackfsdir/doi" 2>/dev/null)
+
+echo "$not_start_value" 2>/dev/null > "$smackfsdir/doi"
+
+direct_value=$(cat "$smackfsdir/doi" 2>/dev/null)
+if [ "$direct_value" != "$not_start_value" ]; then
+ tst_brkm TFAIL "The CIPSO doi reported is \"$direct_value\", not the" \
+ "expected \"$not_start_value\"."
fi
-echo "$StartValue" 2>/dev/null > "$smackfsdir/doi"
+echo "$start_value" 2>/dev/null > "$smackfsdir/doi"
-DirectValue=`cat "$smackfsdir/doi" 2>/dev/null`
-if [ "$DirectValue" != "$StartValue" ]; then
- cat <<EOM
-The CIPSO doi reported is "$DirectValue",
-not the expected "$StartValue".
-EOM
- exit 1
+direct_value=$(cat "$smackfsdir/doi" 2>/dev/null)
+if [ "$direct_value" != "$start_value" ]; then
+ tst_brkm TFAIL "The CIPSO doi reported is \"$direct_value\", not the" \
+ "expected \"$start_value\"."
fi
-exit 0
+tst_resm TPASS "Test \"$TCID\" success."
+tst_exit
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 08/12] smack_set_load.sh: Cleanup
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
` (5 preceding siblings ...)
2014-12-23 9:33 ` [LTP] [PATCH v2 07/12] smack_set_doi.sh: Cleanup Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 09/12] smack_set_netlabel.sh: Cleanup Zeng Linggang
` (3 subsequent siblings)
10 siblings, 0 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* Use 'test.sh' script and use 'tst_*'.
* Add 'TCID' and 'TST_TOTAL' global variables.
* Use '.' instead of 'source'.
* Use '$()' instead of '``'.
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
testcases/kernel/security/smack/smack_set_load.sh | 55 ++++++++++++-----------
1 file changed, 29 insertions(+), 26 deletions(-)
diff --git a/testcases/kernel/security/smack/smack_set_load.sh b/testcases/kernel/security/smack/smack_set_load.sh
index 2dd4fbb..57c04c0 100755
--- a/testcases/kernel/security/smack/smack_set_load.sh
+++ b/testcases/kernel/security/smack/smack_set_load.sh
@@ -14,40 +14,43 @@
# 1 2 3 4 5 6
# 123456789012345678901234567890123456789012345678901234567890123456789
-source smack_common.sh
+export TCID=smack_set_load
+export TST_TOTAL=1
-RuleA="TheOne TheOther rwxa"
-RuleB="TheOne TheOther r---"
+. test.sh
-OldRule=`grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther '`
+. smack_common.sh
-echo -n "$RuleA" 2>/dev/null > "$smackfsdir/load"
-NewRule=`grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther '`
-if [ "$NewRule" = "" ]; then
- echo "Rule did not get set."
- exit 1
+rule_a="TheOne TheOther rwxa"
+rule_b="TheOne TheOther r---"
+
+old_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
+
+echo -n "$rule_a" 2>/dev/null > "$smackfsdir/load"
+new_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
+if [ "$new_rule" = "" ]; then
+ tst_brkm TFAIL "Rule did not get set."
fi
-Mode=`echo "$NewRule" | sed -e 's/.* //'`
-if [ "$Mode" != "rwxa" ]; then
- echo "Rule \"$NewRule\" is not set correctly."
+mode=$(echo "$new_rule" | sed -e 's/.* //')
+if [ "$mode" != "rwxa" ]; then
+ tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
exit 1
fi
-echo -n "$RuleB" 2>/dev/null > "$smackfsdir/load"
-NewRule=`grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther '`
-if [ "$NewRule" = "" ]; then
- echo "Rule did not get set."
- exit 1
+echo -n "$rule_b" 2>/dev/null > "$smackfsdir/load"
+new_rule=$(grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther ')
+if [ "$new_rule" = "" ]; then
+ tst_brkm TFAIL "Rule did not get set."
fi
-Mode=`echo "$NewRule" | sed -e 's/.* //'`
-if [ "$Mode" != "r" ]; then
- echo "Rule \"$NewRule\" is not set correctly."
- exit 1
+mode=$(echo "$new_rule" | sed -e 's/.* //')
+if [ "$mode" != "r" ]; then
+ tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
fi
-if [ "$OldRule" != "$NewRule" ]; then
- cat <<EOM
-Notice: Test access rule changed from
-"$OldRule" to "$NewRule".
-EOM
+if [ "$old_rule" != "$new_rule" ]; then
+ tst_resm TINFO "Notice: Test access rule changed from \"$old_rule\"" \
+ "to \"$new_rule\"."
fi
+
+tst_resm TPASS "Test \"$TCID\" success."
+tst_exit
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 09/12] smack_set_netlabel.sh: Cleanup
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
` (6 preceding siblings ...)
2014-12-23 9:33 ` [LTP] [PATCH v2 08/12] smack_set_load.sh: Cleanup Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 10/12] smack_set_onlycap.sh: Cleanup Zeng Linggang
` (2 subsequent siblings)
10 siblings, 0 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* Use 'test.sh' script and use 'tst_*'.
* Add 'TCID' and 'TST_TOTAL' global variables.
* Use '.' instead of 'source'.
* Use '$()' instead of '``'.
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
.../kernel/security/smack/smack_set_netlabel.sh | 54 +++++++++++-----------
1 file changed, 28 insertions(+), 26 deletions(-)
diff --git a/testcases/kernel/security/smack/smack_set_netlabel.sh b/testcases/kernel/security/smack/smack_set_netlabel.sh
index 4c4a384..9689abf 100755
--- a/testcases/kernel/security/smack/smack_set_netlabel.sh
+++ b/testcases/kernel/security/smack/smack_set_netlabel.sh
@@ -10,39 +10,41 @@
# CAP_MAC_ADMIN
#
-source smack_common.sh
+export TCID=smack_set_netlabel
+export TST_TOTAL=1
-RuleA="191.191.191.191 TheOne"
-RuleA1="191.191.191.191/32 TheOne"
-RuleB="191.190.190.0/24 TheOne"
+. test.sh
-Old32=`grep "^191.191.191.191/32" "$smackfsdir/netlabel" 2>/dev/null`
-Old24=`grep "^191.190.190.0/24" "$smackfsdir/netlabel" 2>/dev/null`
+. smack_common.sh
-echo -n "$RuleA" 2>/dev/null > "$smackfsdir/netlabel"
-New32=`grep "$RuleA1" $smackfsdir/netlabel 2>/dev/null`
-if [ "$New32" != "$RuleA1" ]; then
- echo "Rule \"$RuleA\" did not get set."
- exit 1
+rule_a="191.191.191.191 TheOne"
+rule_a1="191.191.191.191/32 TheOne"
+rule_b="191.190.190.0/24 TheOne"
+
+old32=$(grep "^191.191.191.191/32" "$smackfsdir/netlabel" 2>/dev/null)
+old24=$(grep "^191.190.190.0/24" "$smackfsdir/netlabel" 2>/dev/null)
+
+echo -n "$rule_a" 2>/dev/null > "$smackfsdir/netlabel"
+new32=$(grep "$rule_a1" $smackfsdir/netlabel 2>/dev/null)
+if [ "$new32" != "$rule_a1" ]; then
+ tst_brkm TFAIL "Rule \"$rule_a\" did not get set."
fi
-echo -n "$RuleB" 2>/dev/null > "$smackfsdir/netlabel"
-New24=`grep "$RuleB" "$smackfsdir/netlabel" 2>/dev/null`
-if [ "$New24" != "$RuleB" ]; then
- echo "Rule \"$RuleB\" did not get set."
- exit 1
+echo -n "$rule_b" 2>/dev/null > "$smackfsdir/netlabel"
+new24=$(grep "$rule_b" "$smackfsdir/netlabel" 2>/dev/null)
+if [ "$new24" != "$rule_b" ]; then
+ tst_brkm TFAIL "Rule \"$rule_b\" did not get set."
fi
-if [ "$Old24" != "$New24" ]; then
- cat <<EOM
-Notice: Test access rule changed from
-"$Old24" to "$New24".
-EOM
+if [ "$old24" != "$new24" ]; then
+ tst_resm TINFO "Notice: Test access rule changed from \"$old24\" to" \
+ "\"$new24\"."
fi
-if [ "$Old32" != "$New32" ]; then
- cat <<EOM
-Notice: Test access rule changed from
-"$Old32" to "$New32".
-EOM
+if [ "$old32" != "$new32" ]; then
+ tst_resm TINFO "Notice: Test access rule changed from \"$old32\" to \
+\"$new32\"."
fi
+
+tst_resm TPASS "Test \"$TCID\" success."
+tst_exit
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 10/12] smack_set_onlycap.sh: Cleanup
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
` (7 preceding siblings ...)
2014-12-23 9:33 ` [LTP] [PATCH v2 09/12] smack_set_netlabel.sh: Cleanup Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 11/12] smack: Rename 'notroot.c' to 'smack_notroot.c' Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 12/12] smack_set_socket_labels.c: Cleanup Zeng Linggang
10 siblings, 0 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* Use 'test.sh' script and use 'tst_*'.
* Add 'TCID' and 'TST_TOTAL' global variables.
* Use '.' instead of 'source'.
* Use '$()' instead of '``'.
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
.../kernel/security/smack/smack_set_onlycap.sh | 40 ++++++++++++----------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/testcases/kernel/security/smack/smack_set_onlycap.sh b/testcases/kernel/security/smack/smack_set_onlycap.sh
index 4b7b53a..5753d18 100755
--- a/testcases/kernel/security/smack/smack_set_onlycap.sh
+++ b/testcases/kernel/security/smack/smack_set_onlycap.sh
@@ -10,29 +10,31 @@
# CAP_MAC_ADMIN
#
-source smack_common.sh
+export TCID=smack_set_onlycap
+export TST_TOTAL=1
-MyLabel=`cat /proc/self/attr/current 2>/dev/null`
-StartLabel=`cat "$smackfsdir/onlycap" 2>/dev/null`
+. test.sh
-echo "$MyLabel" 2>/dev/null > "$smackfsdir/onlycap"
+. smack_common.sh
-label=`cat "$smackfsdir/onlycap" 2>/dev/null`
-if [ "$label" != "$MyLabel" ]; then
- cat <<EOM
-The smack label reported for $smackfsdir/onlycap is "$label",
-not the expected "$MyLabel".
-EOM
- exit 1
+my_label=$(cat /proc/self/attr/current 2>/dev/null)
+start_label=$(cat "$smackfsdir/onlycap" 2>/dev/null)
+
+echo "$my_label" 2>/dev/null > "$smackfsdir/onlycap"
+
+label=$(cat "$smackfsdir/onlycap" 2>/dev/null)
+if [ "$label" != "$my_label" ]; then
+ tst_brkm TFAIL "The smack label reported for \"$smackfsdir/onlycap\" "
+ "is \"$label\", not the expected \"$my_label\"."
fi
-echo "$StartLabel" 2>/dev/null > "$smackfsdir/onlycap"
+echo "$start_label" 2>/dev/null > "$smackfsdir/onlycap"
-label=`cat "$smackfsdir/onlycap" 2>/dev/null`
-if [ "$label" != "$StartLabel" ]; then
- cat <<EOM
-The smack label reported for the current process is "$label",
-not the expected "$StartLabel".
-EOM
- exit 1
+label=$(cat "$smackfsdir/onlycap" 2>/dev/null)
+if [ "$label" != "$start_label" ]; then
+ tst_brkm TFAIL "The smack label reported for the current process is "
+ "\"$label\", not the expected \"$start_label\"."
fi
+
+tst_resm TPASS "Test \"$TCID\" success."
+tst_exit
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 11/12] smack: Rename 'notroot.c' to 'smack_notroot.c'
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
` (8 preceding siblings ...)
2014-12-23 9:33 ` [LTP] [PATCH v2 10/12] smack_set_onlycap.sh: Cleanup Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 12/12] smack_set_socket_labels.c: Cleanup Zeng Linggang
10 siblings, 0 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
testcases/kernel/security/smack/.gitignore | 2 +-
testcases/kernel/security/smack/notroot.c | 29 ----------------------
.../kernel/security/smack/smack_file_access.sh | 2 +-
testcases/kernel/security/smack/smack_notroot.c | 29 ++++++++++++++++++++++
4 files changed, 31 insertions(+), 31 deletions(-)
delete mode 100644 testcases/kernel/security/smack/notroot.c
create mode 100644 testcases/kernel/security/smack/smack_notroot.c
diff --git a/testcases/kernel/security/smack/.gitignore b/testcases/kernel/security/smack/.gitignore
index 5e9e819..16d5663 100644
--- a/testcases/kernel/security/smack/.gitignore
+++ b/testcases/kernel/security/smack/.gitignore
@@ -1,2 +1,2 @@
-/notroot
+/smack_notroot
/smack_set_socket_labels
diff --git a/testcases/kernel/security/smack/notroot.c b/testcases/kernel/security/smack/notroot.c
deleted file mode 100644
index 05858d3..0000000
--- a/testcases/kernel/security/smack/notroot.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2007 Casey Schaufler <casey@schaufler-ca.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 2.
- *
- * Author:
- * Casey Schaufler <casey@schaufler-ca.com>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-int main(int argc, char *argv[])
-{
- setuid(1);
-
- execv(argv[1], &argv[1]);
-
- perror(argv[0]);
- exit(1);
-}
diff --git a/testcases/kernel/security/smack/smack_file_access.sh b/testcases/kernel/security/smack/smack_file_access.sh
index a2d09c0..8642715 100755
--- a/testcases/kernel/security/smack/smack_file_access.sh
+++ b/testcases/kernel/security/smack/smack_file_access.sh
@@ -37,7 +37,7 @@ TST_CLEANUP=cleanup
chmod 777 $(pwd)
-notroot /bin/sh -c "echo InitialData 2>/tmp/smack_fail.log > $testfile"
+smack_notroot /bin/sh -c "echo InitialData 2>/tmp/smack_fail.log > $testfile"
if [ ! -f "$testfile" ]; then
tst_brkm TFAIL "Test file \"$testfile\" can not be created."
fi
diff --git a/testcases/kernel/security/smack/smack_notroot.c b/testcases/kernel/security/smack/smack_notroot.c
new file mode 100644
index 0000000..05858d3
--- /dev/null
+++ b/testcases/kernel/security/smack/smack_notroot.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Casey Schaufler <casey@schaufler-ca.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2.
+ *
+ * Author:
+ * Casey Schaufler <casey@schaufler-ca.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+int main(int argc, char *argv[])
+{
+ setuid(1);
+
+ execv(argv[1], &argv[1]);
+
+ perror(argv[0]);
+ exit(1);
+}
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [LTP] [PATCH v2 12/12] smack_set_socket_labels.c: Cleanup
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
` (9 preceding siblings ...)
2014-12-23 9:33 ` [LTP] [PATCH v2 11/12] smack: Rename 'notroot.c' to 'smack_notroot.c' Zeng Linggang
@ 2014-12-23 9:33 ` Zeng Linggang
10 siblings, 0 replies; 17+ messages in thread
From: Zeng Linggang @ 2014-12-23 9:33 UTC (permalink / raw)
To: ltp-list
* Check whether smackfs is set.
* Use 'test.h' and 'tst_*'.
* Modify Makefile.
* Delete 'message'.
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
testcases/kernel/security/smack/Makefile | 2 +-
.../security/smack/smack_set_socket_labels.c | 45 +++++++++++++---------
2 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/testcases/kernel/security/smack/Makefile b/testcases/kernel/security/smack/Makefile
index e114998..6d9abfd 100644
--- a/testcases/kernel/security/smack/Makefile
+++ b/testcases/kernel/security/smack/Makefile
@@ -8,7 +8,7 @@
top_srcdir ?= ../../../..
-include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/testcases.mk
INSTALL_TARGETS := *.sh
diff --git a/testcases/kernel/security/smack/smack_set_socket_labels.c b/testcases/kernel/security/smack/smack_set_socket_labels.c
index 086e4c8..df8c637 100644
--- a/testcases/kernel/security/smack/smack_set_socket_labels.c
+++ b/testcases/kernel/security/smack/smack_set_socket_labels.c
@@ -28,10 +28,16 @@
#endif
#include <sys/xattr.h>
+#include <sys/vfs.h>
+
+#include "test.h"
+#include "usctest.h"
+
+char *TCID = "smack_set_socket_labels";
+int TST_TOTAL = 1;
int main(int argc, char *argv[])
{
- char message[256];
char *anin = "security.SMACK64IPIN";
char *anout = "security.SMACK64IPOUT";
char *annot = "security.SMACK64IPNOT";
@@ -40,35 +46,36 @@ int main(int argc, char *argv[])
char *avnot = "TheBadValue";
int sock;
int rc;
+ char buf[256];
- if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- sprintf(message, "%s Socket creation failure", argv[0]);
- perror(message);
- exit(1);
- }
+ sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (sock = < 0)
+ tst_brkm(TFAIL, NULL, "%s Socket creation failure", argv[0]);
+
+ flistxattr(sock, buf, 256);
+ if (strstr(buf, "security.SMACK64") == NULL)
+ tst_brkm(TCONF, NULL, "smackfs not set.");
rc = fsetxattr(sock, anin, avin, strlen(avin) + 1, 0);
if (rc < 0) {
- sprintf(message, "%s fsetxattr of %s to %s failure",
- argv[0], anin, avin);
- perror(message);
- exit(1);
+ tst_brkm(TFAIL, NULL, "%s fsetxattr of %s to %s failure",
+ argv[0], anin, avin);
}
rc = fsetxattr(sock, anout, avout, strlen(avout) + 1, 0);
if (rc < 0) {
- sprintf(message, "%s fsetxattr of %s to %s failure",
- argv[0], anout, avout);
- perror(message);
- exit(1);
+ tst_brkm(TFAIL, NULL, "%s fsetxattr of %s to %s failure",
+ argv[0], anout, avout);
}
rc = fsetxattr(sock, annot, avnot, strlen(avnot) + 1, 0);
if (rc >= 0) {
- sprintf(message, "%s fsetxattr of %s to %s succeeded in error",
- argv[0], anout, avout);
- perror(message);
- exit(1);
+ tst_brkm(TFAIL, NULL,
+ "%s fsetxattr of %s to %s succeeded in error",
+ argv[0], anout, avout);
}
- exit(0);
+
+ tst_resm(TPASS, "Test %s success.", TCID);
+
+ tst_exit();
}
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [LTP] [PATCH v2 02/12] smack_file_access.sh: Cleanup
2014-12-23 9:33 ` [LTP] [PATCH v2 02/12] smack_file_access.sh: Cleanup Zeng Linggang
@ 2015-01-19 15:51 ` Cyril Hrubis
[not found] ` <1421742761-10192-1-git-send-email-zenglg.jy@cn.fujitsu.com>
0 siblings, 1 reply; 17+ messages in thread
From: Cyril Hrubis @ 2015-01-19 15:51 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
> -if [ ! -d "$Where" ]; then
> - if [ -e "$Where" ]; then
> - echo "Test directory \"$Where\" exists but is not a directory."
> - exit 1
> - fi
> - mkdir -m 777 "$Where"
> - if [ ! -d "$Where" ]; then
> - echo "Test directory \"$Where\" can not be created."
> - exit 1
> - fi
> -fi
> +tst_tmpdir
> +TST_CLEANUP=cleanup
> +
> +chmod 777 $(pwd)
Hmm, we do chmod 777 for the TMPDIR in the C test library. I guess that
it will be better to move the chmod to test.sh and omit it here.
The rest of the patchset looks good to me.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [LTP] [PATCH v3 09/12] smack_set_load.sh: Cleanup
[not found] ` <1421742761-10192-9-git-send-email-zenglg.jy@cn.fujitsu.com>
@ 2015-01-20 13:34 ` Cyril Hrubis
0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2015-01-20 13:34 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
> +mode=$(echo "$new_rule" | sed -e 's/.* //')
> +if [ "$mode" != "rwxa" ]; then
> + tst_brkm TFAIL "Rule \"$new_rule\" is not set correctly."
> exit 1
> fi
I've removed this forgotten exit 1 and pushed the patchset, thanks.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [LTP] [PATCH v3 12/12] smack_set_socket_labels.c: Cleanup
[not found] ` <1421742761-10192-12-git-send-email-zenglg.jy@cn.fujitsu.com>
@ 2015-01-20 13:41 ` Cyril Hrubis
[not found] ` <1421809918-21785-1-git-send-email-zenglg.jy@cn.fujitsu.com>
0 siblings, 1 reply; 17+ messages in thread
From: Cyril Hrubis @ 2015-01-20 13:41 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
> int main(int argc, char *argv[])
> {
> - char message[256];
> char *anin = "security.SMACK64IPIN";
> char *anout = "security.SMACK64IPOUT";
> char *annot = "security.SMACK64IPNOT";
> @@ -40,35 +46,36 @@ int main(int argc, char *argv[])
> char *avnot = "TheBadValue";
> int sock;
> int rc;
> + char buf[256];
We may also put the parse_opts() here and do the TEST_LOOPING(), feel
free to send follow up patch.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [LTP] [PATCH v3 08/12] smack_set_doi.sh: Cleanup
[not found] ` <1421810019.19850.1.camel@G08JYZSD130126.localdomain>
@ 2015-01-21 11:56 ` Cyril Hrubis
0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2015-01-21 11:56 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
> Hi!
>
> Did you forget this patch? ;)
Sorry, I've must have missed it when I was saving them. Pushed now.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [LTP] [PATCH] smack_set_socket_labels.c: Add `parse_opts' and so on.
[not found] ` <1421809918-21785-1-git-send-email-zenglg.jy@cn.fujitsu.com>
@ 2015-01-27 15:28 ` Cyril Hrubis
0 siblings, 0 replies; 17+ messages in thread
From: Cyril Hrubis @ 2015-01-27 15:28 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
> Add `setup' and `cleanup'.
> Add `parse_opts' and `TEST_LOOPING'.
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2015-01-27 15:28 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-23 9:33 [LTP] [PATCH v2 01/12] smack_common.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 02/12] smack_file_access.sh: Cleanup Zeng Linggang
2015-01-19 15:51 ` Cyril Hrubis
[not found] ` <1421742761-10192-1-git-send-email-zenglg.jy@cn.fujitsu.com>
[not found] ` <1421742761-10192-9-git-send-email-zenglg.jy@cn.fujitsu.com>
2015-01-20 13:34 ` [LTP] [PATCH v3 09/12] smack_set_load.sh: Cleanup Cyril Hrubis
[not found] ` <1421742761-10192-12-git-send-email-zenglg.jy@cn.fujitsu.com>
2015-01-20 13:41 ` [LTP] [PATCH v3 12/12] smack_set_socket_labels.c: Cleanup Cyril Hrubis
[not found] ` <1421809918-21785-1-git-send-email-zenglg.jy@cn.fujitsu.com>
2015-01-27 15:28 ` [LTP] [PATCH] smack_set_socket_labels.c: Add `parse_opts' and so on Cyril Hrubis
[not found] ` <1421742761-10192-8-git-send-email-zenglg.jy@cn.fujitsu.com>
[not found] ` <1421810019.19850.1.camel@G08JYZSD130126.localdomain>
2015-01-21 11:56 ` [LTP] [PATCH v3 08/12] smack_set_doi.sh: Cleanup Cyril Hrubis
2014-12-23 9:33 ` [LTP] [PATCH v2 03/12] smack_set_ambient.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 04/12] smack_set_cipso.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 05/12] smack_set_current.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 06/12] smack_set_direct.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 07/12] smack_set_doi.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 08/12] smack_set_load.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 09/12] smack_set_netlabel.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 10/12] smack_set_onlycap.sh: Cleanup Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 11/12] smack: Rename 'notroot.c' to 'smack_notroot.c' Zeng Linggang
2014-12-23 9:33 ` [LTP] [PATCH v2 12/12] smack_set_socket_labels.c: Cleanup Zeng Linggang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox