1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
2f08c3bdfSopenharmony_ci/*
3f08c3bdfSopenharmony_ci * Copyright (C) International Business Machines  Corp., 2001
4f08c3bdfSopenharmony_ci * Ported by Wayne Boyer
5f08c3bdfSopenharmony_ci * Adapted by Dustin Kirkland (k1rkland@us.ibm.com)
6f08c3bdfSopenharmony_ci * Copyright (c) 2022 SUSE LLC Avinesh Kumar <avinesh.kumar@suse.com>
7f08c3bdfSopenharmony_ci */
8f08c3bdfSopenharmony_ci
9f08c3bdfSopenharmony_ci/*\
10f08c3bdfSopenharmony_ci * [Description]
11f08c3bdfSopenharmony_ci *
12f08c3bdfSopenharmony_ci * Verify that setfsuid() syscall fails if an invalid fsuid is given.
13f08c3bdfSopenharmony_ci */
14f08c3bdfSopenharmony_ci
15f08c3bdfSopenharmony_ci#include <pwd.h>
16f08c3bdfSopenharmony_ci#include "tst_test.h"
17f08c3bdfSopenharmony_ci#include "compat_tst_16.h"
18f08c3bdfSopenharmony_ci
19f08c3bdfSopenharmony_cistatic void run(void)
20f08c3bdfSopenharmony_ci{
21f08c3bdfSopenharmony_ci	uid_t invalid_uid, current_uid;
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_ci	current_uid = geteuid();
24f08c3bdfSopenharmony_ci	invalid_uid = (UID_T)-1;
25f08c3bdfSopenharmony_ci
26f08c3bdfSopenharmony_ci	UID16_CHECK(invalid_uid, setfsuid);
27f08c3bdfSopenharmony_ci
28f08c3bdfSopenharmony_ci	TST_EXP_VAL_SILENT(SETFSUID(invalid_uid), (long)current_uid);
29f08c3bdfSopenharmony_ci	TST_EXP_VAL(SETFSUID(invalid_uid), (long)current_uid,
30f08c3bdfSopenharmony_ci		    "setfsuid(invalid_fsuid) test for expected failure:");
31f08c3bdfSopenharmony_ci}
32f08c3bdfSopenharmony_ci
33f08c3bdfSopenharmony_cistatic struct tst_test test = {
34f08c3bdfSopenharmony_ci	.test_all = run
35f08c3bdfSopenharmony_ci};
36