From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Garrett Cooper <yanegomi@gmail.com>
Cc: LTP list <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH ltp] make filecaps tests succeed
Date: Wed, 28 Apr 2010 19:25:30 -0500 [thread overview]
Message-ID: <20100429002530.GA3923@us.ibm.com> (raw)
In-Reply-To: <x2w364299f41004281602h7256b1b8t9a9554cddee90e5d@mail.gmail.com>
Quoting Garrett Cooper (yanegomi@gmail.com):
> On Wed, Apr 28, 2010 at 3:47 PM, Serge E. Hallyn <serue@us.ibm.com> wrote:
> > 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.
> >
> > Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
> > ---
> > 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(-)
> >
> > diff --git a/testcases/kernel/security/filecaps/filecapstest.sh b/testcases/kernel/security/filecaps/filecapstest.sh
> > index 43582dc..6864de4 100755
> > --- a/testcases/kernel/security/filecaps/filecapstest.sh
> > +++ b/testcases/kernel/security/filecaps/filecapstest.sh
> > @@ -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"
>
> 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?
No objection - though then the definition of /tmp/caps_fifo below
needs to be changed as well.
> > +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
> > diff --git a/testcases/kernel/security/filecaps/print_caps.c b/testcases/kernel/security/filecaps/print_caps.c
> > index f0e9bce..b887738 100644
> > --- a/testcases/kernel/security/filecaps/print_caps.c
> > +++ b/testcases/kernel/security/filecaps/print_caps.c
> > @@ -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;
>
> 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.
> > }
> > diff --git a/testcases/kernel/security/filecaps/verify_caps_exec.c b/testcases/kernel/security/filecaps/verify_caps_exec.c
> > index 5250007..7360d4a 100644
> > --- a/testcases/kernel/security/filecaps/verify_caps_exec.c
> > +++ b/testcases/kernel/security/filecaps/verify_caps_exec.c
> > @@ -43,7 +43,7 @@
> > #include <sys/prctl.h>
> > #include <test.h>
> >
> > -#define TSTPATH "./print_caps"
> > +#define TSTPATH "print_caps"
>
> Ok.
>
> > 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);
>
> Why??? This could potentially fubar errno too...
The perror doesn't need to be there.
> > + tst_resm(TBROK | TERRNO, "cap_set_proc failed\n");
> > + tst_exit();
>
> tst_brkm(TBROK | TERRNO, tst_exit, "cap_set..."); is better
>
> > + }
> > 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;
> > --
> > 1.6.0.6
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
prev parent reply other threads:[~2010-04-29 2:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-28 22:47 [LTP] [PATCH ltp] make filecaps tests succeed Serge E. Hallyn
2010-04-28 23:02 ` Garrett Cooper
2010-04-29 0:25 ` Serge E. Hallyn [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100429002530.GA3923@us.ibm.com \
--to=serue@us.ibm.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=yanegomi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.