* [LTP] [PATCH] Add tst_require_root to acct01 testcase.
@ 2011-01-20 13:30 Cristian Greco
2011-01-21 8:28 ` Garrett Cooper
0 siblings, 1 reply; 5+ messages in thread
From: Cristian Greco @ 2011-01-20 13:30 UTC (permalink / raw)
To: ltp-list; +Cc: Cristian Greco
[-- Attachment #1.1: Type: text/plain, Size: 1070 bytes --]
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).
Signed-off-by: Cristian Greco <cristian@regolo.cc>
---
testcases/kernel/syscalls/acct/acct01.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/testcases/kernel/syscalls/acct/acct01.c
b/testcases/kernel/syscalls/acct/acct01.c index 221a30a..dae5598 100644
--- a/testcases/kernel/syscalls/acct/acct01.c
+++ b/testcases/kernel/syscalls/acct/acct01.c
@@ -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
+}
--
1.7.2.3
Thanks,
--
Cristian Greco
GPG key ID: 0xCF4D32E4
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 382 bytes --]
------------------------------------------------------------------------------
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
[-- Attachment #3: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [LTP] [PATCH] Add tst_require_root to acct01 testcase. 2011-01-20 13:30 [LTP] [PATCH] Add tst_require_root to acct01 testcase Cristian Greco @ 2011-01-21 8:28 ` Garrett Cooper 2011-03-03 17:16 ` [LTP] [PATCH] syscalls: acct01: fix testcases [was: Re: [PATCH] Add tst_require_root to acct01 testcase.] Caspar Zhang 0 siblings, 1 reply; 5+ messages in thread From: Garrett Cooper @ 2011-01-21 8:28 UTC (permalink / raw) To: Cristian Greco; +Cc: ltp-list On Thu, Jan 20, 2011 at 5:30 AM, Cristian Greco <cristian@regolo.cc> wrote: > 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 Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH] syscalls: acct01: fix testcases [was: Re: [PATCH] Add tst_require_root to acct01 testcase.] 2011-01-21 8:28 ` Garrett Cooper @ 2011-03-03 17:16 ` Caspar Zhang 2011-03-03 17:42 ` Cristian Greco 2011-03-04 9:28 ` Garrett Cooper 0 siblings, 2 replies; 5+ messages in thread From: Caspar Zhang @ 2011-03-03 17:16 UTC (permalink / raw) To: Garrett Cooper; +Cc: ltp-list [-- Attachment #1: Type: text/plain, Size: 3549 bytes --] On 01/21/2011 04:28 PM, Garrett Cooper wrote: > On Thu, Jan 20, 2011 at 5:30 AM, Cristian Greco <cristian@regolo.cc> wrote: >> > 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 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. Signed-off-by: Caspar Zhang <czhang@redhat.com> --- testcases/kernel/syscalls/acct/acct01.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-) diff --git a/testcases/kernel/syscalls/acct/acct01.c b/testcases/kernel/syscalls/acct/acct01.c index 5314f4f..324d423 100644 --- a/testcases/kernel/syscalls/acct/acct01.c +++ b/testcases/kernel/syscalls/acct/acct01.c @@ -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(); } -- 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 [-- Attachment #2: 0002-syscalls-acct01-fix-testcases.patch --] [-- Type: text/plain, Size: 3064 bytes --] From 5c8d0a1e83c8430a94511a4abc4f086362cd9566 Mon Sep 17 00:00:00 2001 From: Caspar Zhang <czhang@redhat.com> 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. Signed-off-by: Caspar Zhang <czhang@redhat.com> --- testcases/kernel/syscalls/acct/acct01.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-) diff --git a/testcases/kernel/syscalls/acct/acct01.c b/testcases/kernel/syscalls/acct/acct01.c index 5314f4f..324d423 100644 --- a/testcases/kernel/syscalls/acct/acct01.c +++ b/testcases/kernel/syscalls/acct/acct01.c @@ -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(); } -- 1.7.4.1 [-- Attachment #3: Type: text/plain, Size: 429 bytes --] ------------------------------------------------------------------------------ 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 [-- Attachment #4: Type: text/plain, Size: 155 bytes --] _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] syscalls: acct01: fix testcases [was: Re: [PATCH] Add tst_require_root to acct01 testcase.] 2011-03-03 17:16 ` [LTP] [PATCH] syscalls: acct01: fix testcases [was: Re: [PATCH] Add tst_require_root to acct01 testcase.] Caspar Zhang @ 2011-03-03 17:42 ` Cristian Greco 2011-03-04 9:28 ` Garrett Cooper 1 sibling, 0 replies; 5+ messages in thread From: Cristian Greco @ 2011-03-03 17:42 UTC (permalink / raw) To: Caspar Zhang [-- Attachment #1.1: Type: text/plain, Size: 1360 bytes --] On Fri, 04 Mar 2011 01:16:39 +0800 Caspar Zhang <czhang@redhat.com> wrote: > On 01/21/2011 04:28 PM, Garrett Cooper wrote: > > On Thu, Jan 20, 2011 at 5:30 AM, Cristian Greco <cristian@regolo.cc> wrote: > >> > 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 > > 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. 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 [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 836 bytes --] [-- Attachment #2: Type: text/plain, Size: 429 bytes --] ------------------------------------------------------------------------------ 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 [-- Attachment #3: Type: text/plain, Size: 155 bytes --] _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] syscalls: acct01: fix testcases [was: Re: [PATCH] Add tst_require_root to acct01 testcase.] 2011-03-03 17:16 ` [LTP] [PATCH] syscalls: acct01: fix testcases [was: Re: [PATCH] Add tst_require_root to acct01 testcase.] Caspar Zhang 2011-03-03 17:42 ` Cristian Greco @ 2011-03-04 9:28 ` Garrett Cooper 1 sibling, 0 replies; 5+ messages in thread From: Garrett Cooper @ 2011-03-04 9:28 UTC (permalink / raw) To: Caspar Zhang; +Cc: ltp-list On Thu, Mar 3, 2011 at 9:16 AM, Caspar Zhang <czhang@redhat.com> wrote: > On 01/21/2011 04:28 PM, Garrett Cooper wrote: >> On Thu, Jan 20, 2011 at 5:30 AM, Cristian Greco <cristian@regolo.cc> wrote: >>> > 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 > > 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. 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 Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-03-04 9:28 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-01-20 13:30 [LTP] [PATCH] Add tst_require_root to acct01 testcase Cristian Greco 2011-01-21 8:28 ` Garrett Cooper 2011-03-03 17:16 ` [LTP] [PATCH] syscalls: acct01: fix testcases [was: Re: [PATCH] Add tst_require_root to acct01 testcase.] Caspar Zhang 2011-03-03 17:42 ` Cristian Greco 2011-03-04 9:28 ` Garrett Cooper
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox