public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Avinesh Kumar <akumar@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] setegid02.c: Rewrite using new LTP API
Date: Mon, 17 Oct 2022 09:01:17 +0100	[thread overview]
Message-ID: <87ilkiq3oj.fsf@suse.de> (raw)
In-Reply-To: <20220823095116.369-1-akumar@suse.de>

Hello,

Merged! Thanks

Avinesh Kumar <akumar@suse.de> writes:

> Signed-off-by: Avinesh Kumar <akumar@suse.de>
> ---
>  testcases/kernel/syscalls/setegid/setegid02.c | 90 +++++--------------
>  1 file changed, 21 insertions(+), 69 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/setegid/setegid02.c b/testcases/kernel/syscalls/setegid/setegid02.c
> index 7c60a9cf5..66a8a07fb 100644
> --- a/testcases/kernel/syscalls/setegid/setegid02.c
> +++ b/testcases/kernel/syscalls/setegid/setegid02.c
> @@ -1,87 +1,39 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
>  /*
>   * Copyright (c) 2014 Fujitsu Ltd.
>   * Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> - *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms of version 2 of the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> - *
> - * You should have received a copy of the GNU General Public License along
> - * with this program; if not, write the Free Software Foundation, Inc.,
> - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + * Copyright (c) 2022 SUSE LLC Avinesh Kumar <avinesh.kumar@suse.com>
>   */
> -/*
> - * DESCRIPTION
> - *	The calling process is not privileged and euid is not appropriate,
> - *	EPERM should return.
> +
> +/*\
> + * [Description]
> + *
> + * Verify that setegid() fails with EPERM when the calling process is not
> + * privileged and egid does not match the current real group ID,
> + * current effective group ID, or current saved set-group-ID.
>   */
>  
> -#include <errno.h>
>  #include <pwd.h>
> -#include "test.h"
> -#include "safe_macros.h"
> -
> -char *TCID = "setegid02";
> -int TST_TOTAL = 1;
> -static void setup(void);
> -static void setegid_verify(void);
> -static void cleanup(void);
> +#include "tst_test.h"
>  
>  static struct passwd *ltpuser;
>  
> -int main(int argc, char *argv[])
> -{
> -	int lc;
> -
> -	tst_parse_opts(argc, argv, NULL, NULL);
> -
> -	setup();
> -
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -		tst_count = 0;
> -		setegid_verify();
> -	}
> -
> -	cleanup();
> -	tst_exit();
> -}
> -
>  static void setup(void)
>  {
> -	tst_require_root();
> -
> -	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> -
> -	TEST_PAUSE;
> -
> -	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
> -
> -	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
> +	ltpuser = SAFE_GETPWNAM("nobody");
> +	SAFE_SETEUID(ltpuser->pw_uid);
>  }
>  
>  static void setegid_verify(void)
>  {
> -	TEST(setegid(ltpuser->pw_gid));
> -
> -	if (TEST_RETURN != -1) {
> -		tst_resm(TFAIL, "setegid(%d) succeeded unexpectedly",
> -			 ltpuser->pw_gid);
> -		return;
> -	}
> -
> -	if (TEST_ERRNO == EPERM) {
> -		tst_resm(TPASS | TTERRNO, "setegid failed as expected");
> -	} else {
> -		tst_resm(TFAIL | TTERRNO,
> -			 "setegid failed unexpectedly; expected: %d - %s",
> -			 EPERM, strerror(EPERM));
> -	}
> +	TST_EXP_FAIL(setegid(ltpuser->pw_gid),
> +				EPERM,
> +				"setegid(%d)",
> +				ltpuser->pw_gid);
>  }
>  
> -static void cleanup(void)
> -{
> -}
> +static struct tst_test test = {
> +	.setup = setup,
> +	.test_all = setegid_verify,
> +	.needs_root = 1
> +};
> -- 
> 2.37.1


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

      reply	other threads:[~2022-10-17  8:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23  9:51 [LTP] [PATCH] setegid02.c: Rewrite using new LTP API Avinesh Kumar
2022-10-17  8:01 ` Richard Palethorpe [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=87ilkiq3oj.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=akumar@suse.de \
    --cc=ltp@lists.linux.it \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox