1 /* Copyright (C) 2004 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
29 static pthread_barrier_t b3
, b4
;
30 static uid_t prev_ruid
, prev_euid
, prev_suid
, nobody_uid
;
31 static gid_t prev_rgid
, prev_egid
, prev_sgid
, nobody_gid
;
32 enum ACTION
{ PREPARE
, SET
, CHECK_BEFORE
, CHECK_AFTER
};
33 #define TESTNO(arg) ((long int) (arg) & 0xff)
34 #define THREADNO(arg) ((long int) (arg) >> 8)
38 check_prev_uid (int tno
)
40 uid_t ruid
, euid
, suid
;
41 if (getresuid (&ruid
, &euid
, &suid
) < 0)
43 printf ("getresuid failed: %d %m\n", tno
);
47 if (ruid
!= prev_ruid
|| euid
!= prev_euid
|| suid
!= prev_suid
)
49 printf ("uids before in %d (%d %d %d) != (%d %d %d)\n", tno
,
50 ruid
, euid
, suid
, prev_ruid
, prev_euid
, prev_suid
);
57 check_prev_gid (int tno
)
59 gid_t rgid
, egid
, sgid
;
60 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
62 printf ("getresgid failed: %d %m\n", tno
);
66 if (rgid
!= prev_rgid
|| egid
!= prev_egid
|| sgid
!= prev_sgid
)
68 printf ("gids before in %d (%d %d %d) != (%d %d %d)\n", tno
,
69 rgid
, egid
, sgid
, prev_rgid
, prev_egid
, prev_sgid
);
76 test_setuid1 (enum ACTION action
, int tno
)
78 if (action
== PREPARE
)
81 if (action
!= CHECK_AFTER
)
84 if (action
== SET
&& setuid (nobody_uid
) < 0)
86 printf ("setuid failed: %m\n");
90 if (action
!= CHECK_BEFORE
)
92 uid_t ruid
, euid
, suid
;
93 if (getresuid (&ruid
, &euid
, &suid
) < 0)
95 printf ("getresuid failed: %d %m\n", tno
);
99 if (ruid
!= nobody_uid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
101 printf ("after setuid %d (%d %d %d) != (%d %d %d)\n", tno
,
102 ruid
, euid
, suid
, nobody_uid
, nobody_uid
, nobody_uid
);
110 test_setuid2 (enum ACTION action
, int tno
)
112 if (action
== PREPARE
)
114 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
116 printf ("setresuid failed: %m\n");
120 prev_ruid
= nobody_uid
;
121 prev_euid
= nobody_uid
;
125 if (action
!= CHECK_AFTER
)
126 check_prev_uid (tno
);
128 if (action
== SET
&& setuid (prev_suid
) < 0)
130 printf ("setuid failed: %m\n");
134 if (action
!= CHECK_BEFORE
)
136 uid_t ruid
, euid
, suid
;
137 if (getresuid (&ruid
, &euid
, &suid
) < 0)
139 printf ("getresuid failed: %d %m\n", tno
);
143 if (ruid
!= nobody_uid
|| euid
!= prev_suid
|| suid
!= prev_suid
)
145 printf ("after setuid %d (%d %d %d) != (%d %d %d)\n", tno
,
146 ruid
, euid
, suid
, nobody_uid
, prev_suid
, prev_suid
);
154 test_seteuid1 (enum ACTION action
, int tno
)
156 if (action
== PREPARE
)
159 if (action
!= CHECK_AFTER
)
160 check_prev_uid (tno
);
162 if (action
== SET
&& seteuid (nobody_uid
) < 0)
164 printf ("seteuid failed: %m\n");
168 if (action
!= CHECK_BEFORE
)
170 uid_t ruid
, euid
, suid
;
171 if (getresuid (&ruid
, &euid
, &suid
) < 0)
173 printf ("getresuid failed: %d %m\n", tno
);
177 if (ruid
!= prev_ruid
|| euid
!= nobody_uid
|| suid
!= prev_suid
)
179 printf ("after seteuid %d (%d %d %d) != (%d %d %d)\n", tno
,
180 ruid
, euid
, suid
, prev_ruid
, nobody_uid
, prev_suid
);
188 test_seteuid2 (enum ACTION action
, int tno
)
190 if (action
== PREPARE
)
192 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
194 printf ("setresuid failed: %m\n");
198 prev_ruid
= nobody_uid
;
199 prev_euid
= nobody_uid
;
200 nobody_uid
= prev_suid
;
204 test_seteuid1 (action
, tno
);
209 test_setreuid1 (enum ACTION action
, int tno
)
211 if (action
== PREPARE
)
214 if (action
!= CHECK_AFTER
)
215 check_prev_uid (tno
);
217 if (action
== SET
&& setreuid (-1, nobody_uid
) < 0)
219 printf ("setreuid failed: %m\n");
223 if (action
!= CHECK_BEFORE
)
225 uid_t ruid
, euid
, suid
, esuid
;
226 if (getresuid (&ruid
, &euid
, &suid
) < 0)
228 printf ("getresuid failed: %d %m\n", tno
);
232 if (prev_ruid
!= nobody_uid
)
237 if (ruid
!= prev_ruid
|| euid
!= nobody_uid
|| suid
!= esuid
)
239 printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno
,
240 ruid
, euid
, suid
, prev_ruid
, nobody_uid
, esuid
);
248 test_setreuid2 (enum ACTION action
, int tno
)
250 if (action
== PREPARE
)
253 if (action
!= CHECK_AFTER
)
254 check_prev_uid (tno
);
256 if (action
== SET
&& setreuid (nobody_uid
, -1) < 0)
258 printf ("setreuid failed: %m\n");
262 if (action
!= CHECK_BEFORE
)
264 uid_t ruid
, euid
, suid
;
265 if (getresuid (&ruid
, &euid
, &suid
) < 0)
267 printf ("getresuid failed: %d %m\n", tno
);
271 if (ruid
!= nobody_uid
|| euid
!= prev_euid
|| suid
!= prev_euid
)
273 printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno
,
274 ruid
, euid
, suid
, nobody_uid
, prev_euid
, prev_euid
);
282 test_setreuid3 (enum ACTION action
, int tno
)
284 if (action
== PREPARE
)
287 if (action
!= CHECK_AFTER
)
288 check_prev_uid (tno
);
290 if (action
== SET
&& setreuid (nobody_uid
, nobody_uid
) < 0)
292 printf ("setreuid failed: %m\n");
296 if (action
!= CHECK_BEFORE
)
298 uid_t ruid
, euid
, suid
;
299 if (getresuid (&ruid
, &euid
, &suid
) < 0)
301 printf ("getresuid failed: %d %m\n", tno
);
305 if (ruid
!= nobody_uid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
307 printf ("after setreuid %d (%d %d %d) != (%d %d %d)\n", tno
,
308 ruid
, euid
, suid
, nobody_uid
, nobody_uid
, nobody_uid
);
316 test_setreuid4 (enum ACTION action
, int tno
)
318 if (action
== PREPARE
)
320 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
322 printf ("setresuid failed: %m\n");
326 prev_ruid
= nobody_uid
;
327 prev_euid
= nobody_uid
;
328 nobody_uid
= prev_suid
;
332 test_setreuid1 (action
, tno
);
337 test_setresuid1 (enum ACTION action
, int tno
)
339 if (action
== PREPARE
)
342 if (action
!= CHECK_AFTER
)
343 check_prev_uid (tno
);
345 if (action
== SET
&& setresuid (-1, nobody_uid
, -1) < 0)
347 printf ("setresuid failed: %m\n");
351 if (action
!= CHECK_BEFORE
)
353 uid_t ruid
, euid
, suid
;
354 if (getresuid (&ruid
, &euid
, &suid
) < 0)
356 printf ("getresuid failed: %d %m\n", tno
);
360 if (ruid
!= prev_ruid
|| euid
!= nobody_uid
|| suid
!= prev_suid
)
362 printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno
,
363 ruid
, euid
, suid
, prev_ruid
, nobody_uid
, prev_suid
);
371 test_setresuid2 (enum ACTION action
, int tno
)
373 if (action
== PREPARE
)
376 if (action
!= CHECK_AFTER
)
377 check_prev_uid (tno
);
379 if (action
== SET
&& setresuid (prev_euid
, nobody_uid
, nobody_uid
) < 0)
381 printf ("setresuid failed: %m\n");
385 if (action
!= CHECK_BEFORE
)
387 uid_t ruid
, euid
, suid
;
388 if (getresuid (&ruid
, &euid
, &suid
) < 0)
390 printf ("getresuid failed: %d %m\n", tno
);
394 if (ruid
!= prev_euid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
396 printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno
,
397 ruid
, euid
, suid
, prev_euid
, nobody_uid
, nobody_uid
);
405 test_setresuid3 (enum ACTION action
, int tno
)
407 if (action
== PREPARE
)
410 if (action
!= CHECK_AFTER
)
411 check_prev_uid (tno
);
413 if (action
== SET
&& setresuid (nobody_uid
, nobody_uid
, nobody_uid
) < 0)
415 printf ("setresuid failed: %m\n");
419 if (action
!= CHECK_BEFORE
)
421 uid_t ruid
, euid
, suid
;
422 if (getresuid (&ruid
, &euid
, &suid
) < 0)
424 printf ("getresuid failed: %d %m\n", tno
);
428 if (ruid
!= nobody_uid
|| euid
!= nobody_uid
|| suid
!= nobody_uid
)
430 printf ("after setresuid %d (%d %d %d) != (%d %d %d)\n", tno
,
431 ruid
, euid
, suid
, nobody_uid
, nobody_uid
, nobody_uid
);
439 test_setresuid4 (enum ACTION action
, int tno
)
441 if (action
== PREPARE
)
443 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
445 printf ("setresuid failed: %m\n");
449 prev_ruid
= nobody_uid
;
450 prev_euid
= nobody_uid
;
451 nobody_uid
= prev_suid
;
455 test_setresuid1 (action
, tno
);
460 test_setgid1 (enum ACTION action
, int tno
)
462 if (action
== PREPARE
)
465 if (action
!= CHECK_AFTER
)
466 check_prev_gid (tno
);
468 if (action
== SET
&& setgid (nobody_gid
) < 0)
470 printf ("setgid failed: %m\n");
474 if (action
!= CHECK_BEFORE
)
476 gid_t rgid
, egid
, sgid
;
477 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
479 printf ("getresgid failed: %d %m\n", tno
);
483 if (rgid
!= nobody_gid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
485 printf ("after setgid %d (%d %d %d) != (%d %d %d)\n", tno
,
486 rgid
, egid
, sgid
, nobody_gid
, nobody_gid
, nobody_gid
);
494 test_setgid2 (enum ACTION action
, int tno
)
496 if (action
== PREPARE
)
498 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
500 printf ("setresgid failed: %m\n");
504 prev_rgid
= nobody_gid
;
505 prev_egid
= nobody_gid
;
507 if (setresuid (nobody_uid
, nobody_uid
, -1) < 0)
509 printf ("setresuid failed: %m\n");
513 prev_ruid
= nobody_uid
;
514 prev_euid
= nobody_uid
;
518 if (action
!= CHECK_AFTER
)
519 check_prev_gid (tno
);
521 if (action
== SET
&& setgid (prev_sgid
) < 0)
523 printf ("setgid failed: %m\n");
527 if (action
!= CHECK_BEFORE
)
529 gid_t rgid
, egid
, sgid
;
530 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
532 printf ("getresgid failed: %d %m\n", tno
);
536 if (rgid
!= nobody_gid
|| egid
!= prev_sgid
|| sgid
!= prev_sgid
)
538 printf ("after setgid %d (%d %d %d) != (%d %d %d)\n", tno
,
539 rgid
, egid
, sgid
, nobody_gid
, prev_sgid
, prev_sgid
);
547 test_setegid1 (enum ACTION action
, int tno
)
549 if (action
== PREPARE
)
552 if (action
!= CHECK_AFTER
)
553 check_prev_gid (tno
);
555 if (action
== SET
&& setegid (nobody_gid
) < 0)
557 printf ("setegid failed: %m\n");
561 if (action
!= CHECK_BEFORE
)
563 gid_t rgid
, egid
, sgid
;
564 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
566 printf ("getresgid failed: %d %m\n", tno
);
570 if (rgid
!= prev_rgid
|| egid
!= nobody_gid
|| sgid
!= prev_sgid
)
572 printf ("after setegid %d (%d %d %d) != (%d %d %d)\n", tno
,
573 rgid
, egid
, sgid
, prev_rgid
, nobody_gid
, prev_sgid
);
581 test_setegid2 (enum ACTION action
, int tno
)
583 if (action
== PREPARE
)
585 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
587 printf ("setresgid failed: %m\n");
591 prev_rgid
= nobody_gid
;
592 prev_egid
= nobody_gid
;
593 nobody_gid
= prev_sgid
;
597 test_setegid1 (action
, tno
);
602 test_setregid1 (enum ACTION action
, int tno
)
604 if (action
== PREPARE
)
607 if (action
!= CHECK_AFTER
)
608 check_prev_gid (tno
);
610 if (action
== SET
&& setregid (-1, nobody_gid
) < 0)
612 printf ("setregid failed: %m\n");
616 if (action
!= CHECK_BEFORE
)
618 gid_t rgid
, egid
, sgid
, esgid
;
619 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
621 printf ("getresgid failed: %d %m\n", tno
);
625 if (prev_rgid
!= nobody_gid
)
630 if (rgid
!= prev_rgid
|| egid
!= nobody_gid
|| sgid
!= esgid
)
632 printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno
,
633 rgid
, egid
, sgid
, prev_rgid
, nobody_gid
, esgid
);
641 test_setregid2 (enum ACTION action
, int tno
)
643 if (action
== PREPARE
)
646 if (action
!= CHECK_AFTER
)
647 check_prev_gid (tno
);
649 if (action
== SET
&& setregid (nobody_gid
, -1) < 0)
651 printf ("setregid failed: %m\n");
655 if (action
!= CHECK_BEFORE
)
657 gid_t rgid
, egid
, sgid
;
658 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
660 printf ("getresgid failed: %d %m\n", tno
);
664 if (rgid
!= nobody_gid
|| egid
!= prev_egid
|| sgid
!= prev_egid
)
666 printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno
,
667 rgid
, egid
, sgid
, nobody_gid
, prev_egid
, prev_egid
);
675 test_setregid3 (enum ACTION action
, int tno
)
677 if (action
== PREPARE
)
680 if (action
!= CHECK_AFTER
)
681 check_prev_gid (tno
);
683 if (action
== SET
&& setregid (nobody_gid
, nobody_gid
) < 0)
685 printf ("setregid failed: %m\n");
689 if (action
!= CHECK_BEFORE
)
691 gid_t rgid
, egid
, sgid
;
692 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
694 printf ("getresgid failed: %d %m\n", tno
);
698 if (rgid
!= nobody_gid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
700 printf ("after setregid %d (%d %d %d) != (%d %d %d)\n", tno
,
701 rgid
, egid
, sgid
, nobody_gid
, nobody_gid
, nobody_gid
);
709 test_setregid4 (enum ACTION action
, int tno
)
711 if (action
== PREPARE
)
713 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
715 printf ("setresgid failed: %m\n");
719 prev_rgid
= nobody_gid
;
720 prev_egid
= nobody_gid
;
721 nobody_gid
= prev_sgid
;
725 test_setregid1 (action
, tno
);
730 test_setresgid1 (enum ACTION action
, int tno
)
732 if (action
== PREPARE
)
735 if (action
!= CHECK_AFTER
)
736 check_prev_gid (tno
);
738 if (action
== SET
&& setresgid (-1, nobody_gid
, -1) < 0)
740 printf ("setresgid failed: %m\n");
744 if (action
!= CHECK_BEFORE
)
746 gid_t rgid
, egid
, sgid
;
747 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
749 printf ("getresgid failed: %d %m\n", tno
);
753 if (rgid
!= prev_rgid
|| egid
!= nobody_gid
|| sgid
!= prev_sgid
)
755 printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno
,
756 rgid
, egid
, sgid
, prev_rgid
, nobody_gid
, prev_sgid
);
764 test_setresgid2 (enum ACTION action
, int tno
)
766 if (action
== PREPARE
)
769 if (action
!= CHECK_AFTER
)
770 check_prev_gid (tno
);
772 if (action
== SET
&& setresgid (prev_egid
, nobody_gid
, nobody_gid
) < 0)
774 printf ("setresgid failed: %m\n");
778 if (action
!= CHECK_BEFORE
)
780 gid_t rgid
, egid
, sgid
;
781 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
783 printf ("getresgid failed: %d %m\n", tno
);
787 if (rgid
!= prev_egid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
789 printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno
,
790 rgid
, egid
, sgid
, prev_egid
, nobody_gid
, nobody_gid
);
798 test_setresgid3 (enum ACTION action
, int tno
)
800 if (action
== PREPARE
)
803 if (action
!= CHECK_AFTER
)
804 check_prev_gid (tno
);
806 if (action
== SET
&& setresgid (nobody_gid
, nobody_gid
, nobody_gid
) < 0)
808 printf ("setresgid failed: %m\n");
812 if (action
!= CHECK_BEFORE
)
814 gid_t rgid
, egid
, sgid
;
815 if (getresgid (&rgid
, &egid
, &sgid
) < 0)
817 printf ("getresgid failed: %d %m\n", tno
);
821 if (rgid
!= nobody_gid
|| egid
!= nobody_gid
|| sgid
!= nobody_gid
)
823 printf ("after setresgid %d (%d %d %d) != (%d %d %d)\n", tno
,
824 rgid
, egid
, sgid
, nobody_gid
, nobody_gid
, nobody_gid
);
832 test_setresgid4 (enum ACTION action
, int tno
)
834 if (action
== PREPARE
)
836 if (setresgid (nobody_gid
, nobody_gid
, -1) < 0)
838 printf ("setresgid failed: %m\n");
842 prev_rgid
= nobody_gid
;
843 prev_egid
= nobody_gid
;
844 nobody_gid
= prev_sgid
;
848 test_setresgid1 (action
, tno
);
852 static struct setuid_test
855 void (*test
) (enum ACTION
, int tno
);
858 { "setuid1", test_setuid1
},
859 { "setuid2", test_setuid2
},
860 { "seteuid1", test_seteuid1
},
861 { "seteuid2", test_seteuid2
},
862 { "setreuid1", test_setreuid1
},
863 { "setreuid2", test_setreuid2
},
864 { "setreuid3", test_setreuid3
},
865 { "setreuid4", test_setreuid4
},
866 { "setresuid1", test_setresuid1
},
867 { "setresuid2", test_setresuid2
},
868 { "setresuid3", test_setresuid3
},
869 { "setresuid4", test_setresuid4
},
870 { "setgid1", test_setgid1
},
871 { "setgid2", test_setgid2
},
872 { "setegid1", test_setegid1
},
873 { "setegid2", test_setegid2
},
874 { "setregid1", test_setregid1
},
875 { "setregid2", test_setregid2
},
876 { "setregid3", test_setregid3
},
877 { "setregid4", test_setregid4
},
878 { "setresgid1", test_setresgid1
},
879 { "setresgid2", test_setresgid2
},
880 { "setresgid3", test_setresgid3
},
881 { "setresgid4", test_setresgid4
}
888 int e
= pthread_barrier_wait (&b4
);
889 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
891 puts ("barrier_wait failed");
895 setuid_tests
[TESTNO (arg
)].test (CHECK_AFTER
, THREADNO (arg
));
903 setuid_tests
[TESTNO (arg
)].test (CHECK_BEFORE
, THREADNO (arg
));
905 int e
= pthread_barrier_wait (&b3
);
906 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
908 puts ("barrier_wait failed");
917 do_one_test (long int testno
)
919 printf ("%s test\n", setuid_tests
[testno
].name
);
924 setuid_tests
[testno
].test (PREPARE
, 0);
925 setuid_tests
[testno
].test (SET
, 0);
931 printf ("fork failed: %m\n");
936 if (waitpid (pid
, &status
, 0) < 0)
938 printf ("waitpid failed: %m\n");
942 if (!WIFEXITED (status
))
944 puts ("child did not exit");
948 if (WEXITSTATUS (status
))
950 printf ("skipping %s test\n", setuid_tests
[testno
].name
);
957 setuid_tests
[testno
].test (PREPARE
, 0);
960 int e
= pthread_create (&th
, NULL
, tf
, (void *) (testno
| 0x100L
));
963 printf ("create failed: %m\n");
968 e
= pthread_create (&th2
, NULL
, tf
, (void *) (testno
| 0x200L
));
971 printf ("create failed: %m\n");
975 e
= pthread_barrier_wait (&b3
);
976 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
978 puts ("barrier_wait failed");
982 setuid_tests
[testno
].test (SET
, 0);
985 e
= pthread_create (&th3
, NULL
, tf2
, (void *) (testno
| 0x300L
));
988 printf ("create failed: %m\n");
992 e
= pthread_barrier_wait (&b4
);
993 if (e
!= 0 && e
!= PTHREAD_BARRIER_SERIAL_THREAD
)
995 puts ("barrier_wait failed");
1004 printf ("fork failed: %m\n");
1008 if (waitpid (pid
, &status
, 0) < 0)
1010 printf ("waitpid failed: %m\n");
1014 if (!WIFEXITED (status
))
1016 puts ("second child did not exit");
1020 if (WEXITSTATUS (status
))
1021 exit (WEXITSTATUS (status
));
1030 struct passwd
*pwd
= getpwnam ("nobody");
1033 puts ("User nobody doesn't exist");
1036 nobody_uid
= pwd
->pw_uid
;
1037 nobody_gid
= pwd
->pw_gid
;
1039 if (getresuid (&prev_ruid
, &prev_euid
, &prev_suid
) < 0)
1041 printf ("getresuid failed: %m\n");
1045 if (getresgid (&prev_rgid
, &prev_egid
, &prev_sgid
) < 0)
1047 printf ("getresgid failed: %m\n");
1051 if (prev_ruid
== nobody_uid
|| prev_euid
== nobody_uid
1052 || prev_suid
== nobody_uid
)
1054 puts ("already running as user nobody, skipping tests");
1058 if (prev_rgid
== nobody_gid
|| prev_egid
== nobody_gid
1059 || prev_sgid
== nobody_gid
)
1061 puts ("already running as group nobody, skipping tests");
1065 if (pthread_barrier_init (&b3
, NULL
, 3) != 0)
1067 puts ("barrier_init failed");
1071 if (pthread_barrier_init (&b4
, NULL
, 4) != 0)
1073 puts ("barrier_init failed");
1077 for (unsigned long int testno
= 0;
1078 testno
< sizeof (setuid_tests
) / sizeof (setuid_tests
[0]);
1080 do_one_test (testno
);
1084 #define TEST_FUNCTION do_test ()
1085 #include "../test-skeleton.c"