make filecaps tests succeed
PATCH 1/1 make filecaps tests succeed
Most of these are belated cleanup after the move to using /opt/ltp. Also undoing an ill-advised replacement of return with tst_exit. All filecaps tests now succeed on fedora 10.
--- testcases/kernel/security/filecaps/filecapstest.sh | 9 ++++++--- testcases/kernel/security/filecaps/print_caps.c | 3 ++- .../kernel/security/filecaps/verify_caps_exec.c | 19 ++++++++++++++----- 3 files changed, 22 insertions(+), 9 deletions(-)
testcases/kernel/security/filecaps/filecapstest.sh +6 -3
@@ -22,8 +22,11 @@ echo "Running in:" #rm -f print_caps #cp $LTPROOT/testcases/bin/print_caps . -mkfifo caps_fifo -chmod 777 caps_fifo +#FIFOFILE="$LTPROOT/testcases/bin/caps_fifo" +FIFOFILE="/tmp/caps_fifo" +rm -f $FIFOFILE +mkfifo $FIFOFILE +chmod 777 $FIFOFILE exit_code=0 echo "cap_sys_admin tests" verify_caps_exec 0
@@ -46,5 +49,5 @@ if [ $tmp -ne 0 ]; then exit_code=$tmp fi -unlink caps_fifo +unlink $FIFOFILE exit $exit_code
testcases/kernel/security/filecaps/print_caps.c +2 -1
@@ -36,7 +36,7 @@#include <sys/capability.h> #endif -#define FIFOFILE "caps_fifo" +#define FIFOFILE "/tmp/caps_fifo"int main (int argc,char *argv[]) {
@@ -68,4 +68,5 @@ int main(int argc, char *argv[])#else return 0 ;#endif +return 0 ; }
testcases/kernel/security/filecaps/verify_caps_exec.c +14 -5
@@ -43,7 +43,7 @@#include <sys/prctl.h> #include <test.h> -#define TSTPATH "./print_caps" +#define TSTPATH "print_caps"char *TCID ="filecaps" ;int TST_TOTAL =1 ;
@@ -70,7 +70,7 @@ void print_my_caps()cap_free (txt); } -int drop_root (int keep_perms) +void drop_root (int keep_perms) {int ret;
@@ -84,10 +84,19 @@ int drop_root(int keep_perms) }if (keep_perms) {cap_t cap =cap_from_text ("=eip" ); -cap_set_proc (cap); +int ret; +if (!cap) { +tst_resm (TBROK ,"cap_from_text failed\n" ); +tst_exit (); + } + ret =cap_set_proc (cap); +if (ret <0 ) { +perror (cap_set_proc); +tst_resm (TBROK |TERRNO ,"cap_set_proc failed\n" ); +tst_exit (); + }cap_free (cap); } -tst_exit (); }int perms_test (void )
@@ -114,7 +123,7 @@ int perms_test(void)return ret; } -#define FIFOFILE "caps_fifo" +#define FIFOFILE "/tmp/caps_fifo"void create_fifo (void ) {int ret;
Signature · 8 lines
1.6.0.6 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 19 lines · Serge E. Hallyn
Most of these are belated cleanup after the move to using
/opt/ltp. Also undoing an ill-advised replacement of return withtst_exit. All filecaps tests now succeed on fedora 10.Signed-off-by Serge E. Hallyn <[email protected]>---
testcases/kernel/security/filecaps/filecapstest.sh | 9 ++++++---testcases/kernel/security/filecaps/print_caps.c| 3 ++-.../kernel/security/filecaps/verify_caps_exec.c| 19 ++++++++++++++-----3 files changed, 22 insertions(+), 9 deletions(-)testcases/kernel/security/filecaps/filecapstest.sh +0
-0@@ -22,8 +22,11 @@echo "Running in:"
#rm -fprint_caps
#cp $LTPROOT/testcases/bin/print_caps .
testcases/kernel/security/filecaps/filecapstest.sh line 26
Quoted 4 lines
testcases/kernel/security/filecaps/filecapstest.sh +2
-2-mkfifo caps_fifo -chmod 777 caps_fifo +#FIFOFILE="$LTPROOT/testcases/bin/caps_fifo" +FIFOFILE="/tmp/caps_fifo"
Why not
TMP=${TMP:=/tmp}
$TMP/caps_fifo
etc? FWIW if you're in $TMP already, a lot of these changes aren't required, correct?
Quoted 27 lines
testcases/kernel/security/filecaps/filecapstest.sh +3
-0+rm -f $FIFOFILE +mkfifo $FIFOFILE +chmod 777 $FIFOFILEexit_code=0
echo "cap_sys_admintests"
verify_caps_exec 0testcases/kernel/security/filecaps/filecapstest.sh +0
-0@@ -46,5 +49,5 @@ if [ $tmp -ne 0 ]; thenexit_code=$tmp
fitestcases/kernel/security/filecaps/filecapstest.sh +1
-1-unlink caps_fifo +unlink $FIFOFILEexit $exit_code
testcases/kernel/security/filecaps/print_caps.c +1
-1@@ -36,7 +36,7 @@ #include <sys/capability.h> #endif -#define FIFOFILE "caps_fifo" +#define FIFOFILE "/tmp/caps_fifo" int main(int argc, char *argv[]) {
testcases/kernel/security/filecaps/print_caps.c int main(int argc, char *argv[]) · line 71
Quoted 4 lines
testcases/kernel/security/filecaps/print_caps.c +1
-0@@ -68,4 +68,5 @@ int main(int argc, char *argv[]) #else return 0; #endif + return 0;
What's the value returned for #if ..? If it's `return 0', then why not just remove the other two references in the preprocessor blocks?
testcases/kernel/security/filecaps/verify_caps_exec.c line 46
Quoted 11 lines
testcases/kernel/security/filecaps/print_caps.c +0
-0}testcases/kernel/security/filecaps/verify_caps_exec.c +1
-1@@ -43,7 +43,7 @@ #include <sys/prctl.h> #include <test.h> -#define TSTPATH "./print_caps" +#define TSTPATH "print_caps"
Ok.
Quoted 15 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +1
-1char *TCID = "filecaps"; int TST_TOTAL=1;@@ -70,7 +70,7 @@ void print_my_caps() cap_free(txt); } -int drop_root (int keep_perms) +void drop_root (int keep_perms) { int ret;@@ -84,10 +84,19 @@ int drop_root(int keep_perms) } if (keep_perms) {
testcases/kernel/security/filecaps/verify_caps_exec.c int drop_root(int keep_perms) · line 94
Quoted 10 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +8
-1cap_t cap = cap_from_text("=eip"); - cap_set_proc(cap); + int ret; + if (!cap) { + tst_resm(TBROK, "cap_from_text failed\n"); + tst_exit(); + } + ret = cap_set_proc(cap); + if (ret < 0) { + perror(cap_set_proc);
Why??? This could potentially fubar errno too...
testcases/kernel/security/filecaps/verify_caps_exec.c int drop_root(int keep_perms) · line 96
Quoted 2 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +2
-0+ tst_resm(TBROK | TERRNO, "cap_set_proc failed\n"); + tst_exit();
tst_brkm(TBROK | TERRNO, tst_exit, "cap_set..."); is better
Quoted 17 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +2
-3+ } cap_free(cap); } - tst_exit(); } int perms_test(void)@@ -114,7 +123,7 @@ int perms_test(void) return ret; } -#define FIFOFILE "caps_fifo" +#define FIFOFILE "/tmp/caps_fifo" void create_fifo(void) { int ret; --
Quoted 1 line
1.6.0.6
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 27 lines · Garrett Cooper
Quoted 19 lines · Serge E. Hallyn
Most of these are belated cleanup after the move to using
/opt/ltp. Also undoing an ill-advised replacement of return withtst_exit. All filecaps tests now succeed on fedora 10.Signed-off-by Serge E. Hallyn <[email protected]>---
testcases/kernel/security/filecaps/filecapstest.sh | 9 ++++++---testcases/kernel/security/filecaps/print_caps.c| 3 ++-.../kernel/security/filecaps/verify_caps_exec.c| 19 ++++++++++++++-----3 files changed, 22 insertions(+), 9 deletions(-)testcases/kernel/security/filecaps/filecapstest.sh +0
-0@@ -22,8 +22,11 @@echo "Running in:"
#rm -fprint_caps
#cp $LTPROOT/testcases/bin/print_caps .testcases/kernel/security/filecaps/filecapstest.sh line 26
Quoted 4 lines
testcases/kernel/security/filecaps/filecapstest.sh +2
-2-mkfifo caps_fifo -chmod 777 caps_fifo +#FIFOFILE="$LTPROOT/testcases/bin/caps_fifo" +FIFOFILE="/tmp/caps_fifo"Why not
Quoted 5 lines
TMP=${TMP:=/tmp}
$TMP/caps_fifoetc? FWIW if you're in $TMP already, a lot of these changes aren't required, correct?
No objection - though then the definition of /tmp/caps_fifo below needs to be changed as well.
Quoted 24 lines
Quoted 24 lines
testcases/kernel/security/filecaps/filecapstest.sh +3
-0+rm -f $FIFOFILE +mkfifo $FIFOFILE +chmod 777 $FIFOFILEexit_code=0
echo "cap_sys_admintests"
verify_caps_exec 0testcases/kernel/security/filecaps/filecapstest.sh +0
-0@@ -46,5 +49,5 @@ if [ $tmp -ne 0 ]; thenexit_code=$tmp
fitestcases/kernel/security/filecaps/filecapstest.sh +1
-1-unlink caps_fifo +unlink $FIFOFILEexit $exit_code
testcases/kernel/security/filecaps/print_caps.c +1
-1@@ -36,7 +36,7 @@ #include <sys/capability.h> #endif -#define FIFOFILE "caps_fifo" +#define FIFOFILE "/tmp/caps_fifo"
Quoted 10 lines
testcases/kernel/security/filecaps/print_caps.c int main(int argc, char *argv[]) · line 71
Quoted 7 lines
testcases/kernel/security/filecaps/print_caps.c +1
-0int main(int argc, char *argv[]) {@@ -68,4 +68,5 @@ int main(int argc, char *argv[]) #else return 0; #endif + return 0;What's the value returned for #if ..? If it's `return 0', then why not just remove the other two references in the preprocessor blocks?
There was no return in that case. So really we can just get rid of the #else altogether.
Quoted 26 lines
testcases/kernel/security/filecaps/verify_caps_exec.c line 46
Quoted 11 lines
testcases/kernel/security/filecaps/print_caps.c +0
-0}testcases/kernel/security/filecaps/verify_caps_exec.c +1
-1@@ -43,7 +43,7 @@ #include <sys/prctl.h> #include <test.h> -#define TSTPATH "./print_caps" +#define TSTPATH "print_caps"Ok.
Quoted 12 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +1
-1char *TCID = "filecaps"; int TST_TOTAL=1;@@ -70,7 +70,7 @@ void print_my_caps() cap_free(txt); } -int drop_root (int keep_perms) +void drop_root (int keep_perms) { int ret;
Quoted 15 lines
testcases/kernel/security/filecaps/verify_caps_exec.c int drop_root(int keep_perms) · line 94
Quoted 13 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +8
-1@@ -84,10 +84,19 @@ int drop_root(int keep_perms) } if (keep_perms) { cap_t cap = cap_from_text("=eip"); - cap_set_proc(cap); + int ret; + if (!cap) { + tst_resm(TBROK, "cap_from_text failed\n"); + tst_exit(); + } + ret = cap_set_proc(cap); + if (ret < 0) { + perror(cap_set_proc);Why??? This could potentially fubar errno too...
The perror doesn't need to be there.
Quoted 16 lines
testcases/kernel/security/filecaps/verify_caps_exec.c int drop_root(int keep_perms) · line 96
Quoted 2 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +2
-0+ tst_resm(TBROK | TERRNO, "cap_set_proc failed\n"); + tst_exit();
tst_brkm(TBROK | TERRNO, tst_exit, "cap_set..."); is betterQuoted 11 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +1
-1+ } cap_free(cap); } - tst_exit(); } int perms_test(void)@@ -114,7 +123,7 @@ int perms_test(void) return ret; }
Quoted 7 lines
Quoted 7 lines
testcases/kernel/security/filecaps/verify_caps_exec.c +1
-2-#define FIFOFILE "caps_fifo" +#define FIFOFILE "/tmp/caps_fifo" void create_fifo(void) { int ret; --1.6.0.6
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list