1 /* Copyright (C) 2004-2016 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jaku@redhat.com>, 2004.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
28 static pthread_barrier_t b3
, b4
;
29 static uid_t prev_ruid
, prev_euid
, prev_suid
, nobody_uid
;
30 static gid_t prev_rgid
, prev_egid
, prev_sgid
, nobody_gid
;
31 enum ACTION
{ PREPARE
, SET
, CHECK_BEFORE
, CHECK_AFTER
};
32 #define TESTNO(arg) ((long int) (arg) & 0xff)
33 #define THREADNO(arg) ((long int) (arg) >> 8)
37 check_prev_uid (int tno
)
39 uid_t ruid
, euid
, suid
;
40 if (getresuid (&ruid
, &euid
, &suid
) < 0)
42 printf ("getresuid failed: %d %m\n", tno
);
46 if (ruid
!= prev_ruid
|| euid
!= prev_euid
|| suid
!= prev_suid
)
48 printf ("uids before in %d (%d %d %d) != (%d %d %d)\n", tno
,
49 ruid
, euid
, suid
, prev_ruid
, prev_euid
, prev_suid
);
56 check_prev_gid (int tno
)
58 gid_t rgid
, egid
, sgid
;
59 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
61 printf ("getresgid failed: %d %m\n", tno
);
65 if (rgid
!= prev_rgid
|| egid
!= prev_egid
|| sgid
!= prev_sgid
)
67 printf ("gids before in %d (%d %d %d) != (%d %d %d)\n", tno
,
68 rgid
, egid
, sgid
, prev_rgid
, prev_egid
, prev_sgid
);
75 test_setuid1 (enum ACTION action
, int tno
)
77 if (action
== PREPARE
)
80 if (action
!= CHECK_AFTER
)
83 if (action
== SET
&& setuid (nobody_uid
) < 0)
85 printf ("setuid failed: %m\n");
89 if (action
!= CHECK_BEFORE
)
91 uid_t ruid
, euid
, suid
;
92 if (getresuid (&ruid
, &euid
, &suid
) < 0)
94 printf ("getresuid failed: %d %m\n", tno
);
98 if (ruid
!= nobody_uid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
100 printf ("after setuid %d (%d %d %d) != (%d %d %d)\n", tno
,
101 ruid
, euid
, suid
, nobody_uid
, nobody_uid
, nobody_uid
);
109 test_setuid2 (enum ACTION action
, int tno
)
111 if (action
== PREPARE
)
113 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
115 printf ("setresuid failed: %m\n");
119 prev_ruid
= nobody_uid
;
120 prev_euid
= nobody_uid
;
124 if (action
!= CHECK_AFTER
)
125 check_prev_uid (tno
);
127 if (action
== SET
&& setuid (prev_suid
) < 0)
129 printf ("setuid failed: %m\n");
133 if (action
!= CHECK_BEFORE
)
135 uid_t ruid
, euid
, suid
;
136 if (getresuid (&ruid
, &euid
, &suid
) < 0)
138 printf ("getresuid failed: %d %m\n", tno
);
142 if (ruid
!= nobody_uid
|| euid
!= prev_suid
|| suid
!= prev_suid
)
144 printf ("after setuid %d (%d %d %d) != (%d %d %d)\n", tno
,
145 ruid
, euid
, suid
, nobody_uid
, prev_suid
, prev_suid
);
153 test_seteuid1 (enum ACTION action
, int tno
)
155 if (action
== PREPARE
)
158 if (action
!= CHECK_AFTER
)
159 check_prev_uid (tno
);
161 if (action
== SET
&& seteuid (nobody_uid
) < 0)
163 printf ("seteuid failed: %m\n");
167 if (action
!= CHECK_BEFORE
)
169 uid_t ruid
, euid
, suid
;
170 if (getresuid (&ruid
, &euid
, &suid
) < 0)
172 printf ("getresuid failed: %d %m\n", tno
);
176 if (ruid
!= prev_ruid
|| euid
!= nobody_uid
|| suid
!= prev_suid
)
178 printf ("after seteuid %d (%d %d %d) != (%d %d %d)\n", tno
,
179 ruid
, euid
, suid
, prev_ruid
, nobody_uid
, prev_suid
);
187 test_seteuid2 (enum ACTION action
, int tno
)
189 if (action
== PREPARE
)
191 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
193 printf ("setresuid failed: %m\n");
197 prev_ruid
= nobody_uid
;
198 prev_euid
= nobody_uid
;
199 nobody_uid
= prev_suid
;
203 test_seteuid1 (action
, tno
);
208 test_setreuid1 (enum ACTION action
, int tno
)
210 if (action
== PREPARE
)
213 if (action
!= CHECK_AFTER
)
214 check_prev_uid (tno
);
216 if (action
== SET
&& setreuid (-1, nobody_uid
) < 0)
218 printf ("setreuid failed: %m\n");
222 if (action
!= CHECK_BEFORE
)
224 uid_t ruid
, euid
, suid
, esuid
;
225 if (getresuid (&ruid
, &euid
, &suid
) < 0)
227 printf ("getresuid failed: %d %m\n", tno
);
231 if (prev_ruid
!= nobody_uid
)
236 if (ruid
!= prev_ruid
|| euid
!= nobody_uid
|| suid
!= esuid
)
238 printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno
,
239 ruid
, euid
, suid
, prev_ruid
, nobody_uid
, esuid
);
247 test_setreuid2 (enum ACTION action
, int tno
)
249 if (action
== PREPARE
)
252 if (action
!= CHECK_AFTER
)
253 check_prev_uid (tno
);
255 if (action
== SET
&& setreuid (nobody_uid
, -1) < 0)
257 printf ("setreuid failed: %m\n");
261 if (action
!= CHECK_BEFORE
)
263 uid_t ruid
, euid
, suid
;
264 if (getresuid (&ruid
, &euid
, &suid
) < 0)
266 printf ("getresuid failed: %d %m\n", tno
);
270 if (ruid
!= nobody_uid
|| euid
!= prev_euid
|| suid
!= prev_euid
)
272 printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno
,
273 ruid
, euid
, suid
, nobody_uid
, prev_euid
, prev_euid
);
281 test_setreuid3 (enum ACTION action
, int tno
)
283 if (action
== PREPARE
)
286 if (action
!= CHECK_AFTER
)
287 check_prev_uid (tno
);
289 if (action
== SET
&& setreuid (nobody_uid
, nobody_uid
) < 0)
291 printf ("setreuid failed: %m\n");
295 if (action
!= CHECK_BEFORE
)
297 uid_t ruid
, euid
, suid
;
298 if (getresuid (&ruid
, &euid
, &suid
) < 0)
300 printf ("getresuid failed: %d %m\n", tno
);
304 if (ruid
!= nobody_uid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
306 printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno
,
307 ruid
, euid
, suid
, nobody_uid
, nobody_uid
, nobody_uid
);
315 test_setreuid4 (enum ACTION action
, int tno
)
317 if (action
== PREPARE
)
319 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
321 printf ("setresuid failed: %m\n");
325 prev_ruid
= nobody_uid
;
326 prev_euid
= nobody_uid
;
327 nobody_uid
= prev_suid
;
331 test_setreuid1 (action
, tno
);
336 test_setresuid1 (enum ACTION action
, int tno
)
338 if (action
== PREPARE
)
341 if (action
!= CHECK_AFTER
)
342 check_prev_uid (tno
);
344 if (action
== SET
&& setresuid (-1, nobody_uid
, -1) < 0)
346 printf ("setresuid failed: %m\n");
350 if (action
!= CHECK_BEFORE
)
352 uid_t ruid
, euid
, suid
;
353 if (getresuid (&ruid
, &euid
, &suid
) < 0)
355 printf ("getresuid failed: %d %m\n", tno
);
359 if (ruid
!= prev_ruid
|| euid
!= nobody_uid
|| suid
!= prev_suid
)
361 printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno
,
362 ruid
, euid
, suid
, prev_ruid
, nobody_uid
, prev_suid
);
370 test_setresuid2 (enum ACTION action
, int tno
)
372 if (action
== PREPARE
)
375 if (action
!= CHECK_AFTER
)
376 check_prev_uid (tno
);
378 if (action
== SET
&& setresuid (prev_euid
, nobody_uid
, nobody_uid
) < 0)
380 printf ("setresuid failed: %m\n");
384 if (action
!= CHECK_BEFORE
)
386 uid_t ruid
, euid
, suid
;
387 if (getresuid (&ruid
, &euid
, &suid
) < 0)
389 printf ("getresuid failed: %d %m\n", tno
);
393 if (ruid
!= prev_euid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
395 printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno
,
396 ruid
, euid
, suid
, prev_euid
, nobody_uid
, nobody_uid
);
404 test_setresuid3 (enum ACTION action
, int tno
)
406 if (action
== PREPARE
)
409 if (action
!= CHECK_AFTER
)
410 check_prev_uid (tno
);
412 if (action
== SET
&& setresuid (nobody_uid
, nobody_uid
, nobody_uid
) < 0)
414 printf ("setresuid failed: %m\n");
418 if (action
!= CHECK_BEFORE
)
420 uid_t ruid
, euid
, suid
;
421 if (getresuid (&ruid
, &euid
, &suid
) < 0)
423 printf ("getresuid failed: %d %m\n", tno
);
427 if (ruid
!= nobody_uid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
429 printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno
,
430 ruid
, euid
, suid
, nobody_uid
, nobody_uid
, nobody_uid
);
438 test_setresuid4 (enum ACTION action
, int tno
)
440 if (action
== PREPARE
)
442 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
444 printf ("setresuid failed: %m\n");
448 prev_ruid
= nobody_uid
;
449 prev_euid
= nobody_uid
;
450 nobody_uid
= prev_suid
;
454 test_setresuid1 (action
, tno
);
459 test_setgid1 (enum ACTION action
, int tno
)
461 if (action
== PREPARE
)
464 if (action
!= CHECK_AFTER
)
465 check_prev_gid (tno
);
467 if (action
== SET
&& setgid (nobody_gid
) < 0)
469 printf ("setgid failed: %m\n");
473 if (action
!= CHECK_BEFORE
)
475 gid_t rgid
, egid
, sgid
;
476 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
478 printf ("getresgid failed: %d %m\n", tno
);
482 if (rgid
!= nobody_gid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
484 printf ("after setgid %d (%d %d %d) != (%d %d %d)\n", tno
,
485 rgid
, egid
, sgid
, nobody_gid
, nobody_gid
, nobody_gid
);
493 test_setgid2 (enum ACTION action
, int tno
)
495 if (action
== PREPARE
)
497 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
499 printf ("setresgid failed: %m\n");
503 prev_rgid
= nobody_gid
;
504 prev_egid
= nobody_gid
;
506 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
508 printf ("setresuid failed: %m\n");
512 prev_ruid
= nobody_uid
;
513 prev_euid
= nobody_uid
;
517 if (action
!= CHECK_AFTER
)
518 check_prev_gid (tno
);
520 if (action
== SET
&& setgid (prev_sgid
) < 0)
522 printf ("setgid failed: %m\n");
526 if (action
!= CHECK_BEFORE
)
528 gid_t rgid
, egid
, sgid
;
529 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
531 printf ("getresgid failed: %d %m\n", tno
);
535 if (rgid
!= nobody_gid
|| egid
!= prev_sgid
|| sgid
!= prev_sgid
)
537 printf ("after setgid %d (%d %d %d) != (%d %d %d)\n", tno
,
538 rgid
, egid
, sgid
, nobody_gid
, prev_sgid
, prev_sgid
);
546 test_setegid1 (enum ACTION action
, int tno
)
548 if (action
== PREPARE
)
551 if (action
!= CHECK_AFTER
)
552 check_prev_gid (tno
);
554 if (action
== SET
&& setegid (nobody_gid
) < 0)
556 printf ("setegid failed: %m\n");
560 if (action
!= CHECK_BEFORE
)
562 gid_t rgid
, egid
, sgid
;
563 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
565 printf ("getresgid failed: %d %m\n", tno
);
569 if (rgid
!= prev_rgid
|| egid
!= nobody_gid
|| sgid
!= prev_sgid
)
571 printf ("after setegid %d (%d %d %d) != (%d %d %d)\n", tno
,
572 rgid
, egid
, sgid
, prev_rgid
, nobody_gid
, prev_sgid
);
580 test_setegid2 (enum ACTION action
, int tno
)
582 if (action
== PREPARE
)
584 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
586 printf ("setresgid failed: %m\n");
590 prev_rgid
= nobody_gid
;
591 prev_egid
= nobody_gid
;
592 nobody_gid
= prev_sgid
;
596 test_setegid1 (action
, tno
);
601 test_setregid1 (enum ACTION action
, int tno
)
603 if (action
== PREPARE
)
606 if (action
!= CHECK_AFTER
)
607 check_prev_gid (tno
);
609 if (action
== SET
&& setregid (-1, nobody_gid
) < 0)
611 printf ("setregid failed: %m\n");
615 if (action
!= CHECK_BEFORE
)
617 gid_t rgid
, egid
, sgid
, esgid
;
618 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
620 printf ("getresgid failed: %d %m\n", tno
);
624 if (prev_rgid
!= nobody_gid
)
629 if (rgid
!= prev_rgid
|| egid
!= nobody_gid
|| sgid
!= esgid
)
631 printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno
,
632 rgid
, egid
, sgid
, prev_rgid
, nobody_gid
, esgid
);
640 test_setregid2 (enum ACTION action
, int tno
)
642 if (action
== PREPARE
)
645 if (action
!= CHECK_AFTER
)
646 check_prev_gid (tno
);
648 if (action
== SET
&& setregid (nobody_gid
, -1) < 0)
650 printf ("setregid failed: %m\n");
654 if (action
!= CHECK_BEFORE
)
656 gid_t rgid
, egid
, sgid
;
657 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
659 printf ("getresgid failed: %d %m\n", tno
);
663 if (rgid
!= nobody_gid
|| egid
!= prev_egid
|| sgid
!= prev_egid
)
665 printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno
,
666 rgid
, egid
, sgid
, nobody_gid
, prev_egid
, prev_egid
);
674 test_setregid3 (enum ACTION action
, int tno
)
676 if (action
== PREPARE
)
679 if (action
!= CHECK_AFTER
)
680 check_prev_gid (tno
);
682 if (action
== SET
&& setregid (nobody_gid
, nobody_gid
) < 0)
684 printf ("setregid failed: %m\n");
688 if (action
!= CHECK_BEFORE
)
690 gid_t rgid
, egid
, sgid
;
691 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
693 printf ("getresgid failed: %d %m\n", tno
);
697 if (rgid
!= nobody_gid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
699 printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno
,
700 rgid
, egid
, sgid
, nobody_gid
, nobody_gid
, nobody_gid
);
708 test_setregid4 (enum ACTION action
, int tno
)
710 if (action
== PREPARE
)
712 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
714 printf ("setresgid failed: %m\n");
718 prev_rgid
= nobody_gid
;
719 prev_egid
= nobody_gid
;
720 nobody_gid
= prev_sgid
;
724 test_setregid1 (action
, tno
);
729 test_setresgid1 (enum ACTION action
, int tno
)
731 if (action
== PREPARE
)
734 if (action
!= CHECK_AFTER
)
735 check_prev_gid (tno
);
737 if (action
== SET
&& setresgid (-1, nobody_gid
, -1) < 0)
739 printf ("setresgid failed: %m\n");
743 if (action
!= CHECK_BEFORE
)
745 gid_t rgid
, egid
, sgid
;
746 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
748 printf ("getresgid failed: %d %m\n", tno
);
752 if (rgid
!= prev_rgid
|| egid
!= nobody_gid
|| sgid
!= prev_sgid
)
754 printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno
,
755 rgid
, egid
, sgid
, prev_rgid
, nobody_gid
, prev_sgid
);
763 test_setresgid2 (enum ACTION action
, int tno
)
765 if (action
== PREPARE
)
768 if (action
!= CHECK_AFTER
)
769 check_prev_gid (tno
);
771 if (action
== SET
&& setresgid (prev_egid
, nobody_gid
, nobody_gid
) < 0)
773 printf ("setresgid failed: %m\n");
777 if (action
!= CHECK_BEFORE
)
779 gid_t rgid
, egid
, sgid
;
780 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
782 printf ("getresgid failed: %d %m\n", tno
);
786 if (rgid
!= prev_egid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
788 printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno
,
789 rgid
, egid
, sgid
, prev_egid
, nobody_gid
, nobody_gid
);
797 test_setresgid3 (enum ACTION action
, int tno
)
799 if (action
== PREPARE
)
802 if (action
!= CHECK_AFTER
)
803 check_prev_gid (tno
);
805 if (action
== SET
&& setresgid (nobody_gid
, nobody_gid
, nobody_gid
) < 0)
807 printf ("setresgid failed: %m\n");
811 if (action
!= CHECK_BEFORE
)
813 gid_t rgid
, egid
, sgid
;
814 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
816 printf ("getresgid failed: %d %m\n", tno
);
820 if (rgid
!= nobody_gid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
822 printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno
,
823 rgid
, egid
, sgid
, nobody_gid
, nobody_gid
, nobody_gid
);
831 test_setresgid4 (enum ACTION action
, int tno
)
833 if (action
== PREPARE
)
835 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
837 printf ("setresgid failed: %m\n");
841 prev_rgid
= nobody_gid
;
842 prev_egid
= nobody_gid
;
843 nobody_gid
= prev_sgid
;
847 test_setresgid1 (action
, tno
);
851 static struct setuid_test
854 void (*test
) (enum ACTION
, int tno
);
857 { "setuid1", test_setuid1
},
858 { "setuid2", test_setuid2
},
859 { "seteuid1", test_seteuid1
},
860 { "seteuid2", test_seteuid2
},
861 { "setreuid1", test_setreuid1
},
862 { "setreuid2", test_setreuid2
},
863 { "setreuid3", test_setreuid3
},
864 { "setreuid4", test_setreuid4
},
865 { "setresuid1", test_setresuid1
},
866 { "setresuid2", test_setresuid2
},
867 { "setresuid3", test_setresuid3
},
868 { "setresuid4", test_setresuid4
},
869 { "setgid1", test_setgid1
},
870 { "setgid2", test_setgid2
},
871 { "setegid1", test_setegid1
},
872 { "setegid2", test_setegid2
},
873 { "setregid1", test_setregid1
},
874 { "setregid2", test_setregid2
},
875 { "setregid3", test_setregid3
},
876 { "setregid4", test_setregid4
},
877 { "setresgid1", test_setresgid1
},
878 { "setresgid2", test_setresgid2
},
879 { "setresgid3", test_setresgid3
},
880 { "setresgid4", test_setresgid4
}
887 int e
= pthread_barrier_wait (&b4
);
888 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
890 puts ("barrier_wait failed");
894 setuid_tests
[TESTNO (arg
)].test (CHECK_AFTER
, THREADNO (arg
));
902 setuid_tests
[TESTNO (arg
)].test (CHECK_BEFORE
, THREADNO (arg
));
904 int e
= pthread_barrier_wait (&b3
);
905 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
907 puts ("barrier_wait failed");
916 do_one_test (long int testno
)
918 printf ("%s test\n", setuid_tests
[testno
].name
);
923 setuid_tests
[testno
].test (PREPARE
, 0);
924 setuid_tests
[testno
].test (SET
, 0);
930 printf ("fork failed: %m\n");
935 if (waitpid (pid
, &status
, 0) < 0)
937 printf ("waitpid failed: %m\n");
941 if (!WIFEXITED (status
))
943 puts ("child did not exit");
947 if (WEXITSTATUS (status
))
949 printf ("skipping %s test\n", setuid_tests
[testno
].name
);
956 setuid_tests
[testno
].test (PREPARE
, 0);
959 int e
= pthread_create (&th
, NULL
, tf
, (void *) (testno
| 0x100L
));
962 printf ("create failed: %m\n");
967 e
= pthread_create (&th2
, NULL
, tf
, (void *) (testno
| 0x200L
));
970 printf ("create failed: %m\n");
974 e
= pthread_barrier_wait (&b3
);
975 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
977 puts ("barrier_wait failed");
981 setuid_tests
[testno
].test (SET
, 0);
984 e
= pthread_create (&th3
, NULL
, tf2
, (void *) (testno
| 0x300L
));
987 printf ("create failed: %m\n");
991 e
= pthread_barrier_wait (&b4
);
992 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
994 puts ("barrier_wait failed");
1003 printf ("fork failed: %m\n");
1007 if (waitpid (pid
, &status
, 0) < 0)
1009 printf ("waitpid failed: %m\n");
1013 if (!WIFEXITED (status
))
1015 puts ("second child did not exit");
1019 if (WEXITSTATUS (status
))
1020 exit (WEXITSTATUS (status
));
1029 struct passwd
*pwd
= getpwnam ("nobody");
1032 puts ("User nobody doesn't exist");
1035 nobody_uid
= pwd
->pw_uid
;
1036 nobody_gid
= pwd
->pw_gid
;
1038 if (getresuid (&prev_ruid
, &prev_euid
, &prev_suid
) < 0)
1040 printf ("getresuid failed: %m\n");
1044 if (getresgid (&prev_rgid
, &prev_egid
, &prev_sgid
) < 0)
1046 printf ("getresgid failed: %m\n");
1050 if (prev_ruid
== nobody_uid
|| prev_euid
== nobody_uid
1051 || prev_suid
== nobody_uid
)
1053 puts ("already running as user nobody, skipping tests");
1057 if (prev_rgid
== nobody_gid
|| prev_egid
== nobody_gid
1058 || prev_sgid
== nobody_gid
)
1060 puts ("already running as group nobody, skipping tests");
1064 if (pthread_barrier_init (&b3
, NULL
, 3) != 0)
1066 puts ("barrier_init failed");
1070 if (pthread_barrier_init (&b4
, NULL
, 4) != 0)
1072 puts ("barrier_init failed");
1076 for (unsigned long int testno
= 0;
1077 testno
< sizeof (setuid_tests
) / sizeof (setuid_tests
[0]);
1079 do_one_test (testno
);
1083 #define TEST_FUNCTION do_test ()
1084 #include "../test-skeleton.c"