Add tst_require_root to acct01 testcase.
PATCH 1/1 Add tst_require_root to acct01 testcase.
Hi,
[ please keep CC as I'm not currently subscribed to the list ]
please find attached a small fix to check for root privileges in acct(2) testcase (syscalls/acct/acct01.c).
--- testcases/kernel/syscalls/acct/acct01.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
(quoted diff) +0 -0
b/testcases/kernel/syscalls/acct/acct01.c index 221a30a..dae5598 100644
testcases/kernel/syscalls/acct/acct01.c +2 -0
@@ -67,6 +67,8 @@ char *argv[];/*--------------------------------------------------------------*/ +tst_require_root (NULL ); +/* turn off acct, so we are in a known state */ if (acct (NULL ) ==-1 ) {
@@ -171,4 +173,4 @@ char *argv[];tst_exit ();/* THIS CALL DOES NOT RETURN -
EXITS!!
*/ /*--------------------------------------------------------------*/ tst_exit(); -}
\ No newline at end of file
+}
Signature · 6 lines
1.7.2.3 Thanks, -- Cristian Greco GPG key ID: 0xCF4D32E4
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 6 lines · Cristian Greco
Hi,
[ please keep CC as I'm not currently subscribed to the list ]
please find attached a small fix to check for root privileges in acct(2) testcase (
syscalls/acct/acct01.c).
Thanks for spotting the issue. I've fixed it, added a few more
testcases, and discovered what appears to be a kernel bug on 2.6.34 (acct("/tmp/does/not/exist") should fail with == -1 and errno == ENOTDIR) :)...
Cheers,
-Garrett
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH 1/1 syscalls: acct01: fix testcases [was: Re: [PATCH] Add tst_require_root to acct01 testcase.]
Quoted 5 lines · Garrett Cooper
Quoted 4 lines · Cristian Greco
Quoted 4 lines
Hi,
[ please keep CC as I'm not currently subscribed to the list ]
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
please find attached a small fix to check for root privileges in acct(2) testcase (
syscalls/acct/acct01.c).Thanks for spotting the issue. I've fixed it, added a few more
testcases, and discovered what appears to be a kernel bug on 2.6.34 (acct("/tmp/does/not/exist")should fail with == -1 and errno == ENOTDIR) :)...
Cheers,
-Garrett
a follow-up fix for http://article.gmane.org/gmane.linux.ltp/13576 . In fact, it's not a kernel bug of ENOTDIR's failure. ENOTDIR means that you setup a string as directory in argument, but it is actually a file. The patch fixes this failure. The result of given path /tmp/does/not/exist should be expected as ENOENT.
And also, there is a mistake in EPERM case, to restore the permissions, SAFE_SETUID should be used instead of SAFE_SETGID, else it will never recover the permissions.
--- testcases/kernel/syscalls/acct/acct01.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-)
(quoted diff) +0 -0
b/testcases/kernel/syscalls/acct/acct01.c
index 5314f4f..324d423 100644
testcases/kernel/syscalls/acct/acct01.c +15 -13
@@ -96,26 +96,36 @@ int main(int argc, char *argv[])setup (); +/* EISDIR */ if (acct ("/" ) ==-1 && errno ==EISDIR )tst_resm (TPASS ,"Failed with EISDIR as expected" );else tst_brkm (TFAIL |TERRNO , cleanup,"didn't fail as expected; expected EISDIR" ); +/* EACCES */ if (acct ("/dev/null" ) ==-1 && errno ==EACCES )tst_resm (TPASS ,"Failed with EACCES as expected" );else tst_brkm (TFAIL |TERRNO , cleanup,"didn't fail as expected; expected EACCES" ); -if (acct ("/tmp/does/not/exist" ) ==-1 && errno ==ENOTDIR ) +/* ENOENT */ +if (acct ("/tmp/does/not/exist" ) ==-1 && errno ==ENOENT ) +tst_resm (TPASS ,"Failed with ENOENT as expected" ); +else +tst_brkm (TBROK |TERRNO , cleanup, +"didn't fail as expected; expected ENOENT" ); + +/* ENOTDIR */ +if (acct ("/etc/fstab/" ) ==-1 && errno ==ENOTDIR )tst_resm (TPASS ,"Failed with ENOTDIR as expected" );else tst_brkm (TFAIL |TERRNO , cleanup,"didn't fail as expected; expected ENOTDIR" ); +/* EPERM */ sprintf (tmpbuf,"./%s.%d" ,TCID ,getpid ()); - fd =SAFE_CREAT (cleanup, tmpbuf,0777 );SAFE_CLOSE (cleanup, fd);
@@ -123,25 +133,17 @@ int main(int argc, char *argv[])tst_brkm (TBROK |TERRNO , cleanup,"acct failed unexpectedly" ); pwent =SAFE_GETPWNAM (cleanup,"nobody" ); -SAFE_SETEUID (cleanup, pwent->pw_uid);if (acct (tmpbuf) ==-1 && errno ==EPERM ) -tst_resm (TPASS ,"acct failed as expected with EPERM" ); +tst_resm (TPASS ,"Failed with EPERM as expected" );else tst_brkm (TBROK |TERRNO , cleanup, -"acct didn't fail as expected with EPERM" ); - -SAFE_SETEGID (cleanup,0 ); +"didn't fail as expected; expected EPERM" ); +SAFE_SETEUID (cleanup,0 );SAFE_UNLINK (cleanup, tmpbuf); -if (acct (tmpbuf) ==-1 && errno ==ENOENT ) -tst_resm (TPASS ,"acct failed as expected with ENOENT" ); -else -tst_brkm (TBROK |TERRNO , cleanup, -"acct didn't fail as expected with ENOENT" ); -cleanup ();tst_exit (); }
Signature · 8 lines
1.7.4.1 -- Quality Engineer (Kernel) in Red Hat Software (Beijing) Co., R&D Branch http://www.cn.redhat.com/ TEL: +86-10-62608150
From 5c8d0a1e83c8430a94511a4abc4f086362cd9566 Mon Sep 17 00:00:00 2001
From: Caspar Zhang <[email protected]>
Date: Fri, 4 Mar 2011 01:01:55 +0800
Subject: [PATCH 2/2] syscalls: acct01: fix testcases
a follow-up fix for http://article.gmane.org/gmane.linux.ltp/13576 . In fact, it's not a kernel bug of ENOTDIR's failure. ENOTDIR means that you setup a string as directory in argument, but it is actually a file. The patch fixes this failure. The result of given path /tmp/does/not/exist should be expected as ENOENT.
And also, there is a mistake in EPERM case, to restore the permissions, SAFE_SETUID should be used instead of SAFE_SETGID, else it will never recover the permissions.
--- testcases/kernel/syscalls/acct/acct01.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-)
testcases/kernel/syscalls/acct/acct01.c +15 -13
@@ -96,26 +96,36 @@ int main(int argc, char *argv[])setup (); +/* EISDIR */ if (acct ("/" ) ==-1 && errno ==EISDIR )tst_resm (TPASS ,"Failed with EISDIR as expected" );else tst_brkm (TFAIL |TERRNO , cleanup,"didn't fail as expected; expected EISDIR" ); +/* EACCES */ if (acct ("/dev/null" ) ==-1 && errno ==EACCES )tst_resm (TPASS ,"Failed with EACCES as expected" );else tst_brkm (TFAIL |TERRNO , cleanup,"didn't fail as expected; expected EACCES" ); -if (acct ("/tmp/does/not/exist" ) ==-1 && errno ==ENOTDIR ) +/* ENOENT */ +if (acct ("/tmp/does/not/exist" ) ==-1 && errno ==ENOENT ) +tst_resm (TPASS ,"Failed with ENOENT as expected" ); +else +tst_brkm (TBROK |TERRNO , cleanup, +"didn't fail as expected; expected ENOENT" ); + +/* ENOTDIR */ +if (acct ("/etc/fstab/" ) ==-1 && errno ==ENOTDIR )tst_resm (TPASS ,"Failed with ENOTDIR as expected" );else tst_brkm (TFAIL |TERRNO , cleanup,"didn't fail as expected; expected ENOTDIR" ); +/* EPERM */ sprintf (tmpbuf,"./%s.%d" ,TCID ,getpid ()); - fd =SAFE_CREAT (cleanup, tmpbuf,0777 );SAFE_CLOSE (cleanup, fd);
@@ -123,25 +133,17 @@ int main(int argc, char *argv[])tst_brkm (TBROK |TERRNO , cleanup,"acct failed unexpectedly" ); pwent =SAFE_GETPWNAM (cleanup,"nobody" ); -SAFE_SETEUID (cleanup, pwent->pw_uid);if (acct (tmpbuf) ==-1 && errno ==EPERM ) -tst_resm (TPASS ,"acct failed as expected with EPERM" ); +tst_resm (TPASS ,"Failed with EPERM as expected" );else tst_brkm (TBROK |TERRNO , cleanup, -"acct didn't fail as expected with EPERM" ); - -SAFE_SETEGID (cleanup,0 ); +"didn't fail as expected; expected EPERM" ); +SAFE_SETEUID (cleanup,0 );SAFE_UNLINK (cleanup, tmpbuf); -if (acct (tmpbuf) ==-1 && errno ==ENOENT ) -tst_resm (TPASS ,"acct failed as expected with ENOENT" ); -else -tst_brkm (TBROK |TERRNO , cleanup, -"acct didn't fail as expected with ENOENT" ); -cleanup ();tst_exit (); }
Signature · 1 line
1.7.4.1
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH] syscalls: acct01: fix testcases [was: Re: [PATCH] Add tst_require_root to acct01 testcase.]
Quoted 21 lines · On Fri, 04 Mar 2011 01:16:39 +0800 Caspar Zhang <[email protected]> wrote:
Quoted 5 lines · Garrett Cooper
Quoted 4 lines · Cristian Greco
Quoted 4 lines
Hi,
[ please keep CC as I'm not currently subscribed to the list ]
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
please find attached a small fix to check for root privileges in acct(2) testcase (
syscalls/acct/acct01.c).Thanks for spotting the issue. I've fixed it, added a few more
testcases, and discovered what appears to be a kernel bug on 2.6.34 (acct("/tmp/does/not/exist")should fail with == -1 and errno == ENOTDIR) :)...
Cheers,
-Garretta follow-up fix for http://article.gmane.org/gmane.linux.ltp/13576 . In fact, it's not a kernel bug of ENOTDIR's failure. ENOTDIR means that you setup a string as directory in argument, but it is actually a file. The patch fixes this failure. The result of given path
/tmp/does/not/existshould be expected as ENOENT.
Quoted 3 lines
And also, there is a mistake in EPERM case, to restore the permissions,
SAFE_SETUIDshould be used instead ofSAFE_SETGID, else it will never recover the permissions.
Hi Caspar,
I noticed the error today but did not have time to work on it.
Thanks for your work!
--
Cristian Greco
GPG key ID: 0xCF4D32E4
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH] syscalls: acct01: fix testcases [was: Re: [PATCH] Add tst_require_root to acct01 testcase.]
In reply to Caspar ZhangQuoted 21 lines · Caspar Zhang
Quoted 5 lines · Garrett Cooper
Quoted 4 lines · Cristian Greco
Quoted 4 lines
Hi,
[ please keep CC as I'm not currently subscribed to the list ]
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
please find attached a small fix to check for root privileges in acct(2) testcase (
syscalls/acct/acct01.c).Thanks for spotting the issue. I've fixed it, added a few more testcases, and discovered what appears to be a kernel bug on 2.6.34 (
acct("/tmp/does/not/exist")should fail with == -1 and errno == ENOTDIR) :)...
Cheers,
-Garretta follow-up fix for http://article.gmane.org/gmane.linux.ltp/13576 . In fact, it's not a kernel bug of ENOTDIR's failure. ENOTDIR means that you setup a string as directory in argument, but it is actually a file. The patch fixes this failure. The result of given path
/tmp/does/not/existshould be expected as ENOENT.
Quoted 3 lines
And also, there is a mistake in EPERM case, to restore the permissions,
SAFE_SETUIDshould be used instead ofSAFE_SETGID, else it will never recover the permissions.
Yeah, you're right... committed.
Thanks,
-Garrett
------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list