1*49cdfc7eSAndroid Build Coastguard Worker /*
2*49cdfc7eSAndroid Build Coastguard Worker *
3*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) International Business Machines Corp., 2001
4*49cdfc7eSAndroid Build Coastguard Worker *
5*49cdfc7eSAndroid Build Coastguard Worker * This program is free software; you can redistribute it and/or modify
6*49cdfc7eSAndroid Build Coastguard Worker * it under the terms of the GNU General Public License as published by
7*49cdfc7eSAndroid Build Coastguard Worker * the Free Software Foundation; either version 2 of the License, or
8*49cdfc7eSAndroid Build Coastguard Worker * (at your option) any later version.
9*49cdfc7eSAndroid Build Coastguard Worker *
10*49cdfc7eSAndroid Build Coastguard Worker * This program is distributed in the hope that it will be useful,
11*49cdfc7eSAndroid Build Coastguard Worker * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*49cdfc7eSAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13*49cdfc7eSAndroid Build Coastguard Worker * the GNU General Public License for more details.
14*49cdfc7eSAndroid Build Coastguard Worker *
15*49cdfc7eSAndroid Build Coastguard Worker * You should have received a copy of the GNU General Public License
16*49cdfc7eSAndroid Build Coastguard Worker * along with this program; if not, write to the Free Software
17*49cdfc7eSAndroid Build Coastguard Worker * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*49cdfc7eSAndroid Build Coastguard Worker */
19*49cdfc7eSAndroid Build Coastguard Worker
20*49cdfc7eSAndroid Build Coastguard Worker /*
21*49cdfc7eSAndroid Build Coastguard Worker * Test Name: mknod03
22*49cdfc7eSAndroid Build Coastguard Worker *
23*49cdfc7eSAndroid Build Coastguard Worker * Test Description:
24*49cdfc7eSAndroid Build Coastguard Worker * Verify that mknod(2) succeeds when used to create a filesystem
25*49cdfc7eSAndroid Build Coastguard Worker * node with set group-ID bit set on a directory with set group-ID bit set.
26*49cdfc7eSAndroid Build Coastguard Worker * The node created should have set group-ID bit set and its gid should be
27*49cdfc7eSAndroid Build Coastguard Worker * equal to the effective gid of the process.
28*49cdfc7eSAndroid Build Coastguard Worker *
29*49cdfc7eSAndroid Build Coastguard Worker * Expected Result:
30*49cdfc7eSAndroid Build Coastguard Worker * mknod() should return value 0 on success and node created should have
31*49cdfc7eSAndroid Build Coastguard Worker * set group-ID bit set, its gid should be equal to the effective gid of
32*49cdfc7eSAndroid Build Coastguard Worker * the process.
33*49cdfc7eSAndroid Build Coastguard Worker *
34*49cdfc7eSAndroid Build Coastguard Worker * Algorithm:
35*49cdfc7eSAndroid Build Coastguard Worker * Setup:
36*49cdfc7eSAndroid Build Coastguard Worker * Setup signal handling.
37*49cdfc7eSAndroid Build Coastguard Worker * Create temporary directory.
38*49cdfc7eSAndroid Build Coastguard Worker * Pause for SIGUSR1 if option specified.
39*49cdfc7eSAndroid Build Coastguard Worker *
40*49cdfc7eSAndroid Build Coastguard Worker * Test:
41*49cdfc7eSAndroid Build Coastguard Worker * Loop if the proper options are given.
42*49cdfc7eSAndroid Build Coastguard Worker * Execute system call
43*49cdfc7eSAndroid Build Coastguard Worker * Check return code, if system call failed (return=-1)
44*49cdfc7eSAndroid Build Coastguard Worker * Log the errno and Issue a FAIL message.
45*49cdfc7eSAndroid Build Coastguard Worker * Otherwise,
46*49cdfc7eSAndroid Build Coastguard Worker * Verify the Functionality of system call
47*49cdfc7eSAndroid Build Coastguard Worker * if successful,
48*49cdfc7eSAndroid Build Coastguard Worker * Issue Functionality-Pass message.
49*49cdfc7eSAndroid Build Coastguard Worker * Otherwise,
50*49cdfc7eSAndroid Build Coastguard Worker * Issue Functionality-Fail message.
51*49cdfc7eSAndroid Build Coastguard Worker * Cleanup:
52*49cdfc7eSAndroid Build Coastguard Worker * Print errno log and/or timing stats if options given
53*49cdfc7eSAndroid Build Coastguard Worker * Delete the temporary directory created.
54*49cdfc7eSAndroid Build Coastguard Worker *
55*49cdfc7eSAndroid Build Coastguard Worker * Usage: <for command-line>
56*49cdfc7eSAndroid Build Coastguard Worker * mknod03 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
57*49cdfc7eSAndroid Build Coastguard Worker * where, -c n : Run n copies concurrently.
58*49cdfc7eSAndroid Build Coastguard Worker * -f : Turn off functionality Testing.
59*49cdfc7eSAndroid Build Coastguard Worker * -i n : Execute test n times.
60*49cdfc7eSAndroid Build Coastguard Worker * -I x : Execute test for x seconds.
61*49cdfc7eSAndroid Build Coastguard Worker * -P x : Pause for x seconds between iterations.
62*49cdfc7eSAndroid Build Coastguard Worker * -t : Turn on syscall timing.
63*49cdfc7eSAndroid Build Coastguard Worker *
64*49cdfc7eSAndroid Build Coastguard Worker * HISTORY
65*49cdfc7eSAndroid Build Coastguard Worker * 07/2001 Ported by Wayne Boyer
66*49cdfc7eSAndroid Build Coastguard Worker *
67*49cdfc7eSAndroid Build Coastguard Worker * RESTRICTIONS:
68*49cdfc7eSAndroid Build Coastguard Worker * This test should be run by 'super-user' (root) only.
69*49cdfc7eSAndroid Build Coastguard Worker *
70*49cdfc7eSAndroid Build Coastguard Worker */
71*49cdfc7eSAndroid Build Coastguard Worker
72*49cdfc7eSAndroid Build Coastguard Worker #include <stdio.h>
73*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h>
74*49cdfc7eSAndroid Build Coastguard Worker #include <unistd.h>
75*49cdfc7eSAndroid Build Coastguard Worker #include <errno.h>
76*49cdfc7eSAndroid Build Coastguard Worker #include <string.h>
77*49cdfc7eSAndroid Build Coastguard Worker #include <signal.h>
78*49cdfc7eSAndroid Build Coastguard Worker #include <pwd.h>
79*49cdfc7eSAndroid Build Coastguard Worker #include <sys/types.h>
80*49cdfc7eSAndroid Build Coastguard Worker #include <sys/stat.h>
81*49cdfc7eSAndroid Build Coastguard Worker
82*49cdfc7eSAndroid Build Coastguard Worker #include "test.h"
83*49cdfc7eSAndroid Build Coastguard Worker #include "safe_macros.h"
84*49cdfc7eSAndroid Build Coastguard Worker
85*49cdfc7eSAndroid Build Coastguard Worker #define LTPUSER "nobody"
86*49cdfc7eSAndroid Build Coastguard Worker #define MODE_RWX S_IFIFO | S_IRWXU | S_IRWXG | S_IRWXO
87*49cdfc7eSAndroid Build Coastguard Worker #define MODE_SGID S_IFIFO | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO
88*49cdfc7eSAndroid Build Coastguard Worker #define DIR_TEMP "testdir_3"
89*49cdfc7eSAndroid Build Coastguard Worker #define TNODE "tnode_%d"
90*49cdfc7eSAndroid Build Coastguard Worker
91*49cdfc7eSAndroid Build Coastguard Worker struct stat buf; /* struct. to hold stat(2) o/p contents */
92*49cdfc7eSAndroid Build Coastguard Worker struct passwd *user1; /* struct. to hold getpwnam(3) o/p contents */
93*49cdfc7eSAndroid Build Coastguard Worker
94*49cdfc7eSAndroid Build Coastguard Worker char *TCID = "mknod03";
95*49cdfc7eSAndroid Build Coastguard Worker int TST_TOTAL = 1;
96*49cdfc7eSAndroid Build Coastguard Worker char node_name[PATH_MAX]; /* buffer to hold node name created */
97*49cdfc7eSAndroid Build Coastguard Worker
98*49cdfc7eSAndroid Build Coastguard Worker gid_t group1_gid, group2_gid, mygid; /* user and process group id's */
99*49cdfc7eSAndroid Build Coastguard Worker uid_t save_myuid, user1_uid; /* user and process user id's */
100*49cdfc7eSAndroid Build Coastguard Worker pid_t mypid; /* process id */
101*49cdfc7eSAndroid Build Coastguard Worker
102*49cdfc7eSAndroid Build Coastguard Worker void setup(); /* setup function for the test */
103*49cdfc7eSAndroid Build Coastguard Worker void cleanup(); /* cleanup function for the test */
104*49cdfc7eSAndroid Build Coastguard Worker
main(int ac,char ** av)105*49cdfc7eSAndroid Build Coastguard Worker int main(int ac, char **av)
106*49cdfc7eSAndroid Build Coastguard Worker {
107*49cdfc7eSAndroid Build Coastguard Worker int lc;
108*49cdfc7eSAndroid Build Coastguard Worker int fflag;
109*49cdfc7eSAndroid Build Coastguard Worker
110*49cdfc7eSAndroid Build Coastguard Worker tst_parse_opts(ac, av, NULL, NULL);
111*49cdfc7eSAndroid Build Coastguard Worker
112*49cdfc7eSAndroid Build Coastguard Worker setup();
113*49cdfc7eSAndroid Build Coastguard Worker
114*49cdfc7eSAndroid Build Coastguard Worker for (lc = 0; TEST_LOOPING(lc); lc++) {
115*49cdfc7eSAndroid Build Coastguard Worker
116*49cdfc7eSAndroid Build Coastguard Worker tst_count = 0;
117*49cdfc7eSAndroid Build Coastguard Worker
118*49cdfc7eSAndroid Build Coastguard Worker /*
119*49cdfc7eSAndroid Build Coastguard Worker * Attempt to create a filesystem node with group id (sgid)
120*49cdfc7eSAndroid Build Coastguard Worker * bit set on a directory with group id (sgid) bit set
121*49cdfc7eSAndroid Build Coastguard Worker * such that, the node created by mknod(2) should have
122*49cdfc7eSAndroid Build Coastguard Worker * group id (sgid) bit set and node's gid should be equal
123*49cdfc7eSAndroid Build Coastguard Worker * to that of effective gid of the process.
124*49cdfc7eSAndroid Build Coastguard Worker */
125*49cdfc7eSAndroid Build Coastguard Worker TEST(mknod(node_name, MODE_SGID, 0));
126*49cdfc7eSAndroid Build Coastguard Worker
127*49cdfc7eSAndroid Build Coastguard Worker /* Check return code from mknod(2) */
128*49cdfc7eSAndroid Build Coastguard Worker if (TEST_RETURN == -1) {
129*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "mknod(%s, %#o, 0) failed, errno=%d : "
130*49cdfc7eSAndroid Build Coastguard Worker "%s", node_name, MODE_SGID, TEST_ERRNO,
131*49cdfc7eSAndroid Build Coastguard Worker strerror(TEST_ERRNO));
132*49cdfc7eSAndroid Build Coastguard Worker continue;
133*49cdfc7eSAndroid Build Coastguard Worker }
134*49cdfc7eSAndroid Build Coastguard Worker /* Set the functionality flag */
135*49cdfc7eSAndroid Build Coastguard Worker fflag = 1;
136*49cdfc7eSAndroid Build Coastguard Worker
137*49cdfc7eSAndroid Build Coastguard Worker /* Check for node's creation */
138*49cdfc7eSAndroid Build Coastguard Worker if (stat(node_name, &buf) < 0) {
139*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "stat() of %s failed, errno:%d",
140*49cdfc7eSAndroid Build Coastguard Worker node_name, TEST_ERRNO);
141*49cdfc7eSAndroid Build Coastguard Worker /* unset functionality flag */
142*49cdfc7eSAndroid Build Coastguard Worker fflag = 0;
143*49cdfc7eSAndroid Build Coastguard Worker }
144*49cdfc7eSAndroid Build Coastguard Worker
145*49cdfc7eSAndroid Build Coastguard Worker /*
146*49cdfc7eSAndroid Build Coastguard Worker * Skip S_ISGID check
147*49cdfc7eSAndroid Build Coastguard Worker * 0fa3ecd87848 ("Fix up non-directory creation in SGID directories")
148*49cdfc7eSAndroid Build Coastguard Worker * clears S_ISGID for files created by non-group members
149*49cdfc7eSAndroid Build Coastguard Worker */
150*49cdfc7eSAndroid Build Coastguard Worker
151*49cdfc7eSAndroid Build Coastguard Worker /* Verify group ID */
152*49cdfc7eSAndroid Build Coastguard Worker if (buf.st_gid != group2_gid) {
153*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "%s: Incorrect group",
154*49cdfc7eSAndroid Build Coastguard Worker node_name);
155*49cdfc7eSAndroid Build Coastguard Worker /* unset flag as functionality fails */
156*49cdfc7eSAndroid Build Coastguard Worker fflag = 0;
157*49cdfc7eSAndroid Build Coastguard Worker }
158*49cdfc7eSAndroid Build Coastguard Worker if (fflag) {
159*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TPASS, "Functionality of mknod(%s, "
160*49cdfc7eSAndroid Build Coastguard Worker "%#o, 0) successful",
161*49cdfc7eSAndroid Build Coastguard Worker node_name, MODE_SGID);
162*49cdfc7eSAndroid Build Coastguard Worker }
163*49cdfc7eSAndroid Build Coastguard Worker
164*49cdfc7eSAndroid Build Coastguard Worker /* Remove the node for the next go `round */
165*49cdfc7eSAndroid Build Coastguard Worker if (unlink(node_name) == -1) {
166*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TWARN, "unlink(%s) failed, errno:%d %s",
167*49cdfc7eSAndroid Build Coastguard Worker node_name, errno, strerror(errno));
168*49cdfc7eSAndroid Build Coastguard Worker }
169*49cdfc7eSAndroid Build Coastguard Worker }
170*49cdfc7eSAndroid Build Coastguard Worker
171*49cdfc7eSAndroid Build Coastguard Worker /* Change the directory back to temporary directory */
172*49cdfc7eSAndroid Build Coastguard Worker SAFE_CHDIR(cleanup, "..");
173*49cdfc7eSAndroid Build Coastguard Worker
174*49cdfc7eSAndroid Build Coastguard Worker /*
175*49cdfc7eSAndroid Build Coastguard Worker * Invoke cleanup() to delete the test directories created
176*49cdfc7eSAndroid Build Coastguard Worker * in the setup() and exit main().
177*49cdfc7eSAndroid Build Coastguard Worker */
178*49cdfc7eSAndroid Build Coastguard Worker cleanup();
179*49cdfc7eSAndroid Build Coastguard Worker
180*49cdfc7eSAndroid Build Coastguard Worker tst_exit();
181*49cdfc7eSAndroid Build Coastguard Worker }
182*49cdfc7eSAndroid Build Coastguard Worker
183*49cdfc7eSAndroid Build Coastguard Worker /*
184*49cdfc7eSAndroid Build Coastguard Worker * setup(void) - performs all ONE TIME setup for this test.
185*49cdfc7eSAndroid Build Coastguard Worker * Exit the test program on receipt of unexpected signals.
186*49cdfc7eSAndroid Build Coastguard Worker * Create a temporary directory used to hold test directories created
187*49cdfc7eSAndroid Build Coastguard Worker * and change the directory to it.
188*49cdfc7eSAndroid Build Coastguard Worker * Verify that pid of process executing the test is root.
189*49cdfc7eSAndroid Build Coastguard Worker * Create a test directory on temporary directory and set the ownership
190*49cdfc7eSAndroid Build Coastguard Worker * of test directory to guest user and process, change mode permissions
191*49cdfc7eSAndroid Build Coastguard Worker * to set group id bit on it.
192*49cdfc7eSAndroid Build Coastguard Worker * Set the effective uid/gid of the process to that of guest user.
193*49cdfc7eSAndroid Build Coastguard Worker */
setup(void)194*49cdfc7eSAndroid Build Coastguard Worker void setup(void)
195*49cdfc7eSAndroid Build Coastguard Worker {
196*49cdfc7eSAndroid Build Coastguard Worker tst_require_root();
197*49cdfc7eSAndroid Build Coastguard Worker
198*49cdfc7eSAndroid Build Coastguard Worker /* Capture unexpected signals */
199*49cdfc7eSAndroid Build Coastguard Worker tst_sig(NOFORK, DEF_HANDLER, cleanup);
200*49cdfc7eSAndroid Build Coastguard Worker
201*49cdfc7eSAndroid Build Coastguard Worker TEST_PAUSE;
202*49cdfc7eSAndroid Build Coastguard Worker
203*49cdfc7eSAndroid Build Coastguard Worker /* Make a temp dir and cd to it */
204*49cdfc7eSAndroid Build Coastguard Worker tst_tmpdir();
205*49cdfc7eSAndroid Build Coastguard Worker
206*49cdfc7eSAndroid Build Coastguard Worker /* fix permissions on the tmpdir */
207*49cdfc7eSAndroid Build Coastguard Worker if (chmod(".", 0711) != 0) {
208*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, cleanup, "chmod() failed");
209*49cdfc7eSAndroid Build Coastguard Worker }
210*49cdfc7eSAndroid Build Coastguard Worker
211*49cdfc7eSAndroid Build Coastguard Worker /* Save the real user id of the current test process */
212*49cdfc7eSAndroid Build Coastguard Worker save_myuid = getuid();
213*49cdfc7eSAndroid Build Coastguard Worker /* Save the process id of the current test process */
214*49cdfc7eSAndroid Build Coastguard Worker mypid = getpid();
215*49cdfc7eSAndroid Build Coastguard Worker
216*49cdfc7eSAndroid Build Coastguard Worker /* Get the node name to be created in the test */
217*49cdfc7eSAndroid Build Coastguard Worker sprintf(node_name, TNODE, mypid);
218*49cdfc7eSAndroid Build Coastguard Worker
219*49cdfc7eSAndroid Build Coastguard Worker /* Get the uid/gid of ltpuser user */
220*49cdfc7eSAndroid Build Coastguard Worker if ((user1 = getpwnam(LTPUSER)) == NULL) {
221*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, cleanup, "%s not in /etc/passwd", LTPUSER);
222*49cdfc7eSAndroid Build Coastguard Worker }
223*49cdfc7eSAndroid Build Coastguard Worker user1_uid = user1->pw_uid;
224*49cdfc7eSAndroid Build Coastguard Worker group1_gid = user1->pw_gid;
225*49cdfc7eSAndroid Build Coastguard Worker
226*49cdfc7eSAndroid Build Coastguard Worker /* Get the effective group id of the test process */
227*49cdfc7eSAndroid Build Coastguard Worker group2_gid = getegid();
228*49cdfc7eSAndroid Build Coastguard Worker
229*49cdfc7eSAndroid Build Coastguard Worker /*
230*49cdfc7eSAndroid Build Coastguard Worker * Create a test directory under temporary directory with the
231*49cdfc7eSAndroid Build Coastguard Worker * specified mode permissions, with uid/gid set to that of guest
232*49cdfc7eSAndroid Build Coastguard Worker * user and the test process.
233*49cdfc7eSAndroid Build Coastguard Worker */
234*49cdfc7eSAndroid Build Coastguard Worker SAFE_MKDIR(cleanup, DIR_TEMP, MODE_RWX);
235*49cdfc7eSAndroid Build Coastguard Worker SAFE_CHOWN(cleanup, DIR_TEMP, user1_uid, group2_gid);
236*49cdfc7eSAndroid Build Coastguard Worker SAFE_CHMOD(cleanup, DIR_TEMP, MODE_SGID);
237*49cdfc7eSAndroid Build Coastguard Worker
238*49cdfc7eSAndroid Build Coastguard Worker /*
239*49cdfc7eSAndroid Build Coastguard Worker * Verify that test directory created with expected permission modes
240*49cdfc7eSAndroid Build Coastguard Worker * and ownerships.
241*49cdfc7eSAndroid Build Coastguard Worker */
242*49cdfc7eSAndroid Build Coastguard Worker SAFE_STAT(cleanup, DIR_TEMP, &buf);
243*49cdfc7eSAndroid Build Coastguard Worker
244*49cdfc7eSAndroid Build Coastguard Worker /* Verify modes of test directory */
245*49cdfc7eSAndroid Build Coastguard Worker if (!(buf.st_mode & S_ISGID)) {
246*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, cleanup,
247*49cdfc7eSAndroid Build Coastguard Worker "%s: Incorrect modes, setgid bit not set", DIR_TEMP);
248*49cdfc7eSAndroid Build Coastguard Worker }
249*49cdfc7eSAndroid Build Coastguard Worker
250*49cdfc7eSAndroid Build Coastguard Worker /* Verify group ID of test directory */
251*49cdfc7eSAndroid Build Coastguard Worker if (buf.st_gid != group2_gid) {
252*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, cleanup, "%s: Incorrect group", DIR_TEMP);
253*49cdfc7eSAndroid Build Coastguard Worker }
254*49cdfc7eSAndroid Build Coastguard Worker
255*49cdfc7eSAndroid Build Coastguard Worker /*
256*49cdfc7eSAndroid Build Coastguard Worker * Set the effective group id and user id of the test process
257*49cdfc7eSAndroid Build Coastguard Worker * to that of guest user (nobody)
258*49cdfc7eSAndroid Build Coastguard Worker */
259*49cdfc7eSAndroid Build Coastguard Worker SAFE_SETGID(cleanup, group1_gid);
260*49cdfc7eSAndroid Build Coastguard Worker if (setreuid(-1, user1_uid) < 0) {
261*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, cleanup,
262*49cdfc7eSAndroid Build Coastguard Worker "Unable to set process uid to that of ltp user");
263*49cdfc7eSAndroid Build Coastguard Worker }
264*49cdfc7eSAndroid Build Coastguard Worker
265*49cdfc7eSAndroid Build Coastguard Worker /* Save the real group ID of the current process */
266*49cdfc7eSAndroid Build Coastguard Worker mygid = getgid();
267*49cdfc7eSAndroid Build Coastguard Worker
268*49cdfc7eSAndroid Build Coastguard Worker /* Change directory to DIR_TEMP */
269*49cdfc7eSAndroid Build Coastguard Worker SAFE_CHDIR(cleanup, DIR_TEMP);
270*49cdfc7eSAndroid Build Coastguard Worker }
271*49cdfc7eSAndroid Build Coastguard Worker
272*49cdfc7eSAndroid Build Coastguard Worker /*
273*49cdfc7eSAndroid Build Coastguard Worker * cleanup() - Performs all ONE TIME cleanup for this test at
274*49cdfc7eSAndroid Build Coastguard Worker * completion or premature exit.
275*49cdfc7eSAndroid Build Coastguard Worker * Print test timing stats and errno log if test executed with options.
276*49cdfc7eSAndroid Build Coastguard Worker * Restore the real/effective user id of the process changed during
277*49cdfc7eSAndroid Build Coastguard Worker * setup().
278*49cdfc7eSAndroid Build Coastguard Worker * Remove temporary directory and sub-directories/files under it
279*49cdfc7eSAndroid Build Coastguard Worker * created during setup().
280*49cdfc7eSAndroid Build Coastguard Worker * Exit the test program with normal exit code.
281*49cdfc7eSAndroid Build Coastguard Worker */
cleanup(void)282*49cdfc7eSAndroid Build Coastguard Worker void cleanup(void)
283*49cdfc7eSAndroid Build Coastguard Worker {
284*49cdfc7eSAndroid Build Coastguard Worker
285*49cdfc7eSAndroid Build Coastguard Worker /*
286*49cdfc7eSAndroid Build Coastguard Worker * Restore the effective uid of the process changed in the
287*49cdfc7eSAndroid Build Coastguard Worker * setup().
288*49cdfc7eSAndroid Build Coastguard Worker */
289*49cdfc7eSAndroid Build Coastguard Worker if (setreuid(-1, save_myuid) < 0) {
290*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, NULL,
291*49cdfc7eSAndroid Build Coastguard Worker "resetting process real/effective uid failed");
292*49cdfc7eSAndroid Build Coastguard Worker }
293*49cdfc7eSAndroid Build Coastguard Worker
294*49cdfc7eSAndroid Build Coastguard Worker tst_rmdir();
295*49cdfc7eSAndroid Build Coastguard Worker
296*49cdfc7eSAndroid Build Coastguard Worker }
297