[LTP] [PATCH] setreuid06: Rewrite the test using new LTP API

Richard Palethorpe rpalethorpe@suse.de
Mon Jan 16 12:42:20 CET 2023


Hello,

Merged, with a minor change. See below.

Avinesh Kumar <akumar@suse.de> writes:

> Signed-off-by: Avinesh Kumar <akumar@suse.de>
> ---
>  .../kernel/syscalls/setreuid/setreuid06.c     | 108 ++++++------------
>  1 file changed, 34 insertions(+), 74 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/setreuid/setreuid06.c b/testcases/kernel/syscalls/setreuid/setreuid06.c
> index 22acd996f..72c7e5e47 100644
> --- a/testcases/kernel/syscalls/setreuid/setreuid06.c
> +++ b/testcases/kernel/syscalls/setreuid/setreuid06.c
> @@ -1,95 +1,55 @@
> +// SPDX-License-Identifier: GPL-2.0-later
>  /*
>   * Copyright (c) International Business Machines  Corp., 2001
> - *
> - * This program is free software;  you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY;  without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> - * the GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program;  if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> - *
>   * Ported by John George
> + * Copyright (c) 2023 SUSE LLC Avinesh Kumar <avinesh.kumar@suse.com>
>   */
>  
> -/*
> - * Test that EPERM is set when setreuid is given an invalid user id.
> +/*\
> + * [Description]
> + *
> + * Verify that setreuid(2) syscall fails with EPERM errno when the calling
> + * process is not privileged and a change other than
> + * (i) swapping the effective user ID with the real user ID, or
> + * (ii) setting one to the value of the other or
> + * (iii) setting the effective user ID to the value of the saved set-user-ID
> + * was specified.
>   */
>  
> -#include <sys/wait.h>
> -#include <limits.h>
> -#include <signal.h>
> -#include <errno.h>
> -#include <unistd.h>
>  #include <pwd.h>
> -#include <sys/param.h>
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -
> -#include "test.h"
> -#include "safe_macros.h"
> -#include "compat_16.h"
> -
> -#define INVAL_USER		 (USHRT_MAX-2)
> -
> -TCID_DEFINE(setreuid06);
> -int TST_TOTAL = 1;
> +#include "tst_test.h"
> +#include "tst_uid.h"
> +#include "compat_tst_16.h"
>  
>  static struct passwd *ltpuser;
> +static uid_t other_uid;
>  
> -static void setup(void);
> -static void cleanup(void);
> -
> -int main(int argc, char **argv)
> +static void setup(void)
>  {
> -	int lc;
> -
> -	tst_parse_opts(argc, argv, NULL, NULL);
> -
> -	setup();
> +	uid_t test_user[1];
>  
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -		tst_count = 0;
> +	tst_get_uids(test_user, 0, 1);

We can just pass a pointer to other_uid.

Thanks!

-- 
Thank you,
Richard.


More information about the ltp mailing list