2
0

setid.c 575 B

123456789101112131415161718192021222324
  1. /*
  2. * The process joins process group 0.
  3. */
  4. #include <stdio.h>
  5. #include <sys/types.h>
  6. #include <unistd.h>
  7. int main(void) {
  8. if( setpgid( getpid(), 0 ) == -1 ) {
  9. perror( "setpgid" );
  10. }
  11. printf( "%d belongs to process group %d\n",
  12. getpid(), getpgrp() );
  13. if( setregid(-1, -1) == -1 ) {
  14. perror( "setregid" );
  15. }
  16. printf("%d has egid %d and gid %d\n", getpid(), getegid(), getgid());
  17. if( setreuid(-1, -1) == -1 ) {
  18. perror( "setreuid" );
  19. }
  20. printf("%d has euid %d and uid %d\n", getpid(), geteuid(), getuid());
  21. }