1 /* Copyright (C) 2004-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
27 static pthread_barrier_t b3
, b4
;
28 static uid_t prev_ruid
, prev_euid
, prev_suid
, nobody_uid
;
29 static gid_t prev_rgid
, prev_egid
, prev_sgid
, nobody_gid
;
30 enum ACTION
{ PREPARE
, SET
, CHECK_BEFORE
, CHECK_AFTER
};
31 #define TESTNO(arg) ((long int) (arg) & 0xff)
32 #define THREADNO(arg) ((long int) (arg) >> 8)
36 check_prev_uid (int tno
)
38 uid_t ruid
, euid
, suid
;
39 if (getresuid (&ruid
, &euid
, &suid
) < 0)
41 printf ("getresuid failed: %d %m\n", tno
);
45 if (ruid
!= prev_ruid
|| euid
!= prev_euid
|| suid
!= prev_suid
)
47 printf ("uids before in %d (%d %d %d) != (%d %d %d)\n", tno
,
48 ruid
, euid
, suid
, prev_ruid
, prev_euid
, prev_suid
);
55 check_prev_gid (int tno
)
57 gid_t rgid
, egid
, sgid
;
58 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
60 printf ("getresgid failed: %d %m\n", tno
);
64 if (rgid
!= prev_rgid
|| egid
!= prev_egid
|| sgid
!= prev_sgid
)
66 printf ("gids before in %d (%d %d %d) != (%d %d %d)\n", tno
,
67 rgid
, egid
, sgid
, prev_rgid
, prev_egid
, prev_sgid
);
74 test_setuid1 (enum ACTION action
, int tno
)
76 if (action
== PREPARE
)
79 if (action
!= CHECK_AFTER
)
82 if (action
== SET
&& setuid (nobody_uid
) < 0)
84 printf ("setuid failed: %m\n");
88 if (action
!= CHECK_BEFORE
)
90 uid_t ruid
, euid
, suid
;
91 if (getresuid (&ruid
, &euid
, &suid
) < 0)
93 printf ("getresuid failed: %d %m\n", tno
);
97 if (ruid
!= nobody_uid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
99 printf ("after setuid %d (%d %d %d) != (%d %d %d)\n", tno
,
100 ruid
, euid
, suid
, nobody_uid
, nobody_uid
, nobody_uid
);
108 test_setuid2 (enum ACTION action
, int tno
)
110 if (action
== PREPARE
)
112 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
114 printf ("setresuid failed: %m\n");
118 prev_ruid
= nobody_uid
;
119 prev_euid
= nobody_uid
;
123 if (action
!= CHECK_AFTER
)
124 check_prev_uid (tno
);
126 if (action
== SET
&& setuid (prev_suid
) < 0)
128 printf ("setuid failed: %m\n");
132 if (action
!= CHECK_BEFORE
)
134 uid_t ruid
, euid
, suid
;
135 if (getresuid (&ruid
, &euid
, &suid
) < 0)
137 printf ("getresuid failed: %d %m\n", tno
);
141 if (ruid
!= nobody_uid
|| euid
!= prev_suid
|| suid
!= prev_suid
)
143 printf ("after setuid %d (%d %d %d) != (%d %d %d)\n", tno
,
144 ruid
, euid
, suid
, nobody_uid
, prev_suid
, prev_suid
);
152 test_seteuid1 (enum ACTION action
, int tno
)
154 if (action
== PREPARE
)
157 if (action
!= CHECK_AFTER
)
158 check_prev_uid (tno
);
160 if (action
== SET
&& seteuid (nobody_uid
) < 0)
162 printf ("seteuid failed: %m\n");
166 if (action
!= CHECK_BEFORE
)
168 uid_t ruid
, euid
, suid
;
169 if (getresuid (&ruid
, &euid
, &suid
) < 0)
171 printf ("getresuid failed: %d %m\n", tno
);
175 if (ruid
!= prev_ruid
|| euid
!= nobody_uid
|| suid
!= prev_suid
)
177 printf ("after seteuid %d (%d %d %d) != (%d %d %d)\n", tno
,
178 ruid
, euid
, suid
, prev_ruid
, nobody_uid
, prev_suid
);
186 test_seteuid2 (enum ACTION action
, int tno
)
188 if (action
== PREPARE
)
190 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
192 printf ("setresuid failed: %m\n");
196 prev_ruid
= nobody_uid
;
197 prev_euid
= nobody_uid
;
198 nobody_uid
= prev_suid
;
202 test_seteuid1 (action
, tno
);
207 test_setreuid1 (enum ACTION action
, int tno
)
209 if (action
== PREPARE
)
212 if (action
!= CHECK_AFTER
)
213 check_prev_uid (tno
);
215 if (action
== SET
&& setreuid (-1, nobody_uid
) < 0)
217 printf ("setreuid failed: %m\n");
221 if (action
!= CHECK_BEFORE
)
223 uid_t ruid
, euid
, suid
, esuid
;
224 if (getresuid (&ruid
, &euid
, &suid
) < 0)
226 printf ("getresuid failed: %d %m\n", tno
);
230 if (prev_ruid
!= nobody_uid
)
235 if (ruid
!= prev_ruid
|| euid
!= nobody_uid
|| suid
!= esuid
)
237 printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno
,
238 ruid
, euid
, suid
, prev_ruid
, nobody_uid
, esuid
);
246 test_setreuid2 (enum ACTION action
, int tno
)
248 if (action
== PREPARE
)
251 if (action
!= CHECK_AFTER
)
252 check_prev_uid (tno
);
254 if (action
== SET
&& setreuid (nobody_uid
, -1) < 0)
256 printf ("setreuid failed: %m\n");
260 if (action
!= CHECK_BEFORE
)
262 uid_t ruid
, euid
, suid
;
263 if (getresuid (&ruid
, &euid
, &suid
) < 0)
265 printf ("getresuid failed: %d %m\n", tno
);
269 if (ruid
!= nobody_uid
|| euid
!= prev_euid
|| suid
!= prev_euid
)
271 printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno
,
272 ruid
, euid
, suid
, nobody_uid
, prev_euid
, prev_euid
);
280 test_setreuid3 (enum ACTION action
, int tno
)
282 if (action
== PREPARE
)
285 if (action
!= CHECK_AFTER
)
286 check_prev_uid (tno
);
288 if (action
== SET
&& setreuid (nobody_uid
, nobody_uid
) < 0)
290 printf ("setreuid failed: %m\n");
294 if (action
!= CHECK_BEFORE
)
296 uid_t ruid
, euid
, suid
;
297 if (getresuid (&ruid
, &euid
, &suid
) < 0)
299 printf ("getresuid failed: %d %m\n", tno
);
303 if (ruid
!= nobody_uid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
305 printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno
,
306 ruid
, euid
, suid
, nobody_uid
, nobody_uid
, nobody_uid
);
314 test_setreuid4 (enum ACTION action
, int tno
)
316 if (action
== PREPARE
)
318 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
320 printf ("setresuid failed: %m\n");
324 prev_ruid
= nobody_uid
;
325 prev_euid
= nobody_uid
;
326 nobody_uid
= prev_suid
;
330 test_setreuid1 (action
, tno
);
335 test_setresuid1 (enum ACTION action
, int tno
)
337 if (action
== PREPARE
)
340 if (action
!= CHECK_AFTER
)
341 check_prev_uid (tno
);
343 if (action
== SET
&& setresuid (-1, nobody_uid
, -1) < 0)
345 printf ("setresuid failed: %m\n");
349 if (action
!= CHECK_BEFORE
)
351 uid_t ruid
, euid
, suid
;
352 if (getresuid (&ruid
, &euid
, &suid
) < 0)
354 printf ("getresuid failed: %d %m\n", tno
);
358 if (ruid
!= prev_ruid
|| euid
!= nobody_uid
|| suid
!= prev_suid
)
360 printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno
,
361 ruid
, euid
, suid
, prev_ruid
, nobody_uid
, prev_suid
);
369 test_setresuid2 (enum ACTION action
, int tno
)
371 if (action
== PREPARE
)
374 if (action
!= CHECK_AFTER
)
375 check_prev_uid (tno
);
377 if (action
== SET
&& setresuid (prev_euid
, nobody_uid
, nobody_uid
) < 0)
379 printf ("setresuid failed: %m\n");
383 if (action
!= CHECK_BEFORE
)
385 uid_t ruid
, euid
, suid
;
386 if (getresuid (&ruid
, &euid
, &suid
) < 0)
388 printf ("getresuid failed: %d %m\n", tno
);
392 if (ruid
!= prev_euid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
394 printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno
,
395 ruid
, euid
, suid
, prev_euid
, nobody_uid
, nobody_uid
);
403 test_setresuid3 (enum ACTION action
, int tno
)
405 if (action
== PREPARE
)
408 if (action
!= CHECK_AFTER
)
409 check_prev_uid (tno
);
411 if (action
== SET
&& setresuid (nobody_uid
, nobody_uid
, nobody_uid
) < 0)
413 printf ("setresuid failed: %m\n");
417 if (action
!= CHECK_BEFORE
)
419 uid_t ruid
, euid
, suid
;
420 if (getresuid (&ruid
, &euid
, &suid
) < 0)
422 printf ("getresuid failed: %d %m\n", tno
);
426 if (ruid
!= nobody_uid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
428 printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno
,
429 ruid
, euid
, suid
, nobody_uid
, nobody_uid
, nobody_uid
);
437 test_setresuid4 (enum ACTION action
, int tno
)
439 if (action
== PREPARE
)
441 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
443 printf ("setresuid failed: %m\n");
447 prev_ruid
= nobody_uid
;
448 prev_euid
= nobody_uid
;
449 nobody_uid
= prev_suid
;
453 test_setresuid1 (action
, tno
);
458 test_setgid1 (enum ACTION action
, int tno
)
460 if (action
== PREPARE
)
463 if (action
!= CHECK_AFTER
)
464 check_prev_gid (tno
);
466 if (action
== SET
&& setgid (nobody_gid
) < 0)
468 printf ("setgid failed: %m\n");
472 if (action
!= CHECK_BEFORE
)
474 gid_t rgid
, egid
, sgid
;
475 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
477 printf ("getresgid failed: %d %m\n", tno
);
481 if (rgid
!= nobody_gid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
483 printf ("after setgid %d (%d %d %d) != (%d %d %d)\n", tno
,
484 rgid
, egid
, sgid
, nobody_gid
, nobody_gid
, nobody_gid
);
492 test_setgid2 (enum ACTION action
, int tno
)
494 if (action
== PREPARE
)
496 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
498 printf ("setresgid failed: %m\n");
502 prev_rgid
= nobody_gid
;
503 prev_egid
= nobody_gid
;
505 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
507 printf ("setresuid failed: %m\n");
511 prev_ruid
= nobody_uid
;
512 prev_euid
= nobody_uid
;
516 if (action
!= CHECK_AFTER
)
517 check_prev_gid (tno
);
519 if (action
== SET
&& setgid (prev_sgid
) < 0)
521 printf ("setgid failed: %m\n");
525 if (action
!= CHECK_BEFORE
)
527 gid_t rgid
, egid
, sgid
;
528 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
530 printf ("getresgid failed: %d %m\n", tno
);
534 if (rgid
!= nobody_gid
|| egid
!= prev_sgid
|| sgid
!= prev_sgid
)
536 printf ("after setgid %d (%d %d %d) != (%d %d %d)\n", tno
,
537 rgid
, egid
, sgid
, nobody_gid
, prev_sgid
, prev_sgid
);
545 test_setegid1 (enum ACTION action
, int tno
)
547 if (action
== PREPARE
)
550 if (action
!= CHECK_AFTER
)
551 check_prev_gid (tno
);
553 if (action
== SET
&& setegid (nobody_gid
) < 0)
555 printf ("setegid failed: %m\n");
559 if (action
!= CHECK_BEFORE
)
561 gid_t rgid
, egid
, sgid
;
562 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
564 printf ("getresgid failed: %d %m\n", tno
);
568 if (rgid
!= prev_rgid
|| egid
!= nobody_gid
|| sgid
!= prev_sgid
)
570 printf ("after setegid %d (%d %d %d) != (%d %d %d)\n", tno
,
571 rgid
, egid
, sgid
, prev_rgid
, nobody_gid
, prev_sgid
);
579 test_setegid2 (enum ACTION action
, int tno
)
581 if (action
== PREPARE
)
583 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
585 printf ("setresgid failed: %m\n");
589 prev_rgid
= nobody_gid
;
590 prev_egid
= nobody_gid
;
591 nobody_gid
= prev_sgid
;
595 test_setegid1 (action
, tno
);
600 test_setregid1 (enum ACTION action
, int tno
)
602 if (action
== PREPARE
)
605 if (action
!= CHECK_AFTER
)
606 check_prev_gid (tno
);
608 if (action
== SET
&& setregid (-1, nobody_gid
) < 0)
610 printf ("setregid failed: %m\n");
614 if (action
!= CHECK_BEFORE
)
616 gid_t rgid
, egid
, sgid
, esgid
;
617 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
619 printf ("getresgid failed: %d %m\n", tno
);
623 if (prev_rgid
!= nobody_gid
)
628 if (rgid
!= prev_rgid
|| egid
!= nobody_gid
|| sgid
!= esgid
)
630 printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno
,
631 rgid
, egid
, sgid
, prev_rgid
, nobody_gid
, esgid
);
639 test_setregid2 (enum ACTION action
, int tno
)
641 if (action
== PREPARE
)
644 if (action
!= CHECK_AFTER
)
645 check_prev_gid (tno
);
647 if (action
== SET
&& setregid (nobody_gid
, -1) < 0)
649 printf ("setregid failed: %m\n");
653 if (action
!= CHECK_BEFORE
)
655 gid_t rgid
, egid
, sgid
;
656 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
658 printf ("getresgid failed: %d %m\n", tno
);
662 if (rgid
!= nobody_gid
|| egid
!= prev_egid
|| sgid
!= prev_egid
)
664 printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno
,
665 rgid
, egid
, sgid
, nobody_gid
, prev_egid
, prev_egid
);
673 test_setregid3 (enum ACTION action
, int tno
)
675 if (action
== PREPARE
)
678 if (action
!= CHECK_AFTER
)
679 check_prev_gid (tno
);
681 if (action
== SET
&& setregid (nobody_gid
, nobody_gid
) < 0)
683 printf ("setregid failed: %m\n");
687 if (action
!= CHECK_BEFORE
)
689 gid_t rgid
, egid
, sgid
;
690 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
692 printf ("getresgid failed: %d %m\n", tno
);
696 if (rgid
!= nobody_gid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
698 printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno
,
699 rgid
, egid
, sgid
, nobody_gid
, nobody_gid
, nobody_gid
);
707 test_setregid4 (enum ACTION action
, int tno
)
709 if (action
== PREPARE
)
711 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
713 printf ("setresgid failed: %m\n");
717 prev_rgid
= nobody_gid
;
718 prev_egid
= nobody_gid
;
719 nobody_gid
= prev_sgid
;
723 test_setregid1 (action
, tno
);
728 test_setresgid1 (enum ACTION action
, int tno
)
730 if (action
== PREPARE
)
733 if (action
!= CHECK_AFTER
)
734 check_prev_gid (tno
);
736 if (action
== SET
&& setresgid (-1, nobody_gid
, -1) < 0)
738 printf ("setresgid failed: %m\n");
742 if (action
!= CHECK_BEFORE
)
744 gid_t rgid
, egid
, sgid
;
745 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
747 printf ("getresgid failed: %d %m\n", tno
);
751 if (rgid
!= prev_rgid
|| egid
!= nobody_gid
|| sgid
!= prev_sgid
)
753 printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno
,
754 rgid
, egid
, sgid
, prev_rgid
, nobody_gid
, prev_sgid
);
762 test_setresgid2 (enum ACTION action
, int tno
)
764 if (action
== PREPARE
)
767 if (action
!= CHECK_AFTER
)
768 check_prev_gid (tno
);
770 if (action
== SET
&& setresgid (prev_egid
, nobody_gid
, nobody_gid
) < 0)
772 printf ("setresgid failed: %m\n");
776 if (action
!= CHECK_BEFORE
)
778 gid_t rgid
, egid
, sgid
;
779 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
781 printf ("getresgid failed: %d %m\n", tno
);
785 if (rgid
!= prev_egid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
787 printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno
,
788 rgid
, egid
, sgid
, prev_egid
, nobody_gid
, nobody_gid
);
796 test_setresgid3 (enum ACTION action
, int tno
)
798 if (action
== PREPARE
)
801 if (action
!= CHECK_AFTER
)
802 check_prev_gid (tno
);
804 if (action
== SET
&& setresgid (nobody_gid
, nobody_gid
, nobody_gid
) < 0)
806 printf ("setresgid failed: %m\n");
810 if (action
!= CHECK_BEFORE
)
812 gid_t rgid
, egid
, sgid
;
813 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
815 printf ("getresgid failed: %d %m\n", tno
);
819 if (rgid
!= nobody_gid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
821 printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno
,
822 rgid
, egid
, sgid
, nobody_gid
, nobody_gid
, nobody_gid
);
830 test_setresgid4 (enum ACTION action
, int tno
)
832 if (action
== PREPARE
)
834 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
836 printf ("setresgid failed: %m\n");
840 prev_rgid
= nobody_gid
;
841 prev_egid
= nobody_gid
;
842 nobody_gid
= prev_sgid
;
846 test_setresgid1 (action
, tno
);
850 static struct setuid_test
853 void (*test
) (enum ACTION
, int tno
);
856 { "setuid1", test_setuid1
},
857 { "setuid2", test_setuid2
},
858 { "seteuid1", test_seteuid1
},
859 { "seteuid2", test_seteuid2
},
860 { "setreuid1", test_setreuid1
},
861 { "setreuid2", test_setreuid2
},
862 { "setreuid3", test_setreuid3
},
863 { "setreuid4", test_setreuid4
},
864 { "setresuid1", test_setresuid1
},
865 { "setresuid2", test_setresuid2
},
866 { "setresuid3", test_setresuid3
},
867 { "setresuid4", test_setresuid4
},
868 { "setgid1", test_setgid1
},
869 { "setgid2", test_setgid2
},
870 { "setegid1", test_setegid1
},
871 { "setegid2", test_setegid2
},
872 { "setregid1", test_setregid1
},
873 { "setregid2", test_setregid2
},
874 { "setregid3", test_setregid3
},
875 { "setregid4", test_setregid4
},
876 { "setresgid1", test_setresgid1
},
877 { "setresgid2", test_setresgid2
},
878 { "setresgid3", test_setresgid3
},
879 { "setresgid4", test_setresgid4
}
886 int e
= pthread_barrier_wait (&b4
);
887 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
889 puts ("barrier_wait failed");
893 setuid_tests
[TESTNO (arg
)].test (CHECK_AFTER
, THREADNO (arg
));
901 setuid_tests
[TESTNO (arg
)].test (CHECK_BEFORE
, THREADNO (arg
));
903 int e
= pthread_barrier_wait (&b3
);
904 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
906 puts ("barrier_wait failed");
915 do_one_test (long int testno
)
917 printf ("%s test\n", setuid_tests
[testno
].name
);
922 setuid_tests
[testno
].test (PREPARE
, 0);
923 setuid_tests
[testno
].test (SET
, 0);
929 printf ("fork failed: %m\n");
934 if (waitpid (pid
, &status
, 0) < 0)
936 printf ("waitpid failed: %m\n");
940 if (!WIFEXITED (status
))
942 puts ("child did not exit");
946 if (WEXITSTATUS (status
))
948 printf ("skipping %s test\n", setuid_tests
[testno
].name
);
955 setuid_tests
[testno
].test (PREPARE
, 0);
958 int e
= pthread_create (&th
, NULL
, tf
, (void *) (testno
| 0x100L
));
961 printf ("create failed: %m\n");
966 e
= pthread_create (&th2
, NULL
, tf
, (void *) (testno
| 0x200L
));
969 printf ("create failed: %m\n");
973 e
= pthread_barrier_wait (&b3
);
974 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
976 puts ("barrier_wait failed");
980 setuid_tests
[testno
].test (SET
, 0);
983 e
= pthread_create (&th3
, NULL
, tf2
, (void *) (testno
| 0x300L
));
986 printf ("create failed: %m\n");
990 e
= pthread_barrier_wait (&b4
);
991 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
993 puts ("barrier_wait failed");
1002 printf ("fork failed: %m\n");
1006 if (waitpid (pid
, &status
, 0) < 0)
1008 printf ("waitpid failed: %m\n");
1012 if (!WIFEXITED (status
))
1014 puts ("second child did not exit");
1018 if (WEXITSTATUS (status
))
1019 exit (WEXITSTATUS (status
));
1028 struct passwd
*pwd
= getpwnam ("nobody");
1031 puts ("User nobody doesn't exist");
1034 nobody_uid
= pwd
->pw_uid
;
1035 nobody_gid
= pwd
->pw_gid
;
1037 if (getresuid (&prev_ruid
, &prev_euid
, &prev_suid
) < 0)
1039 printf ("getresuid failed: %m\n");
1043 if (getresgid (&prev_rgid
, &prev_egid
, &prev_sgid
) < 0)
1045 printf ("getresgid failed: %m\n");
1049 if (prev_ruid
== nobody_uid
|| prev_euid
== nobody_uid
1050 || prev_suid
== nobody_uid
)
1052 puts ("already running as user nobody, skipping tests");
1056 if (prev_rgid
== nobody_gid
|| prev_egid
== nobody_gid
1057 || prev_sgid
== nobody_gid
)
1059 puts ("already running as group nobody, skipping tests");
1063 if (pthread_barrier_init (&b3
, NULL
, 3) != 0)
1065 puts ("barrier_init failed");
1069 if (pthread_barrier_init (&b4
, NULL
, 4) != 0)
1071 puts ("barrier_init failed");
1075 for (unsigned long int testno
= 0;
1076 testno
< sizeof (setuid_tests
) / sizeof (setuid_tests
[0]);
1078 do_one_test (testno
);
1082 #define TEST_FUNCTION do_test ()
1083 #include "../test-skeleton.c"