Skip to content

Instantly share code, notes, and snippets.

@kosaki
Created July 28, 2014 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kosaki/fe1fd0739618857150a4 to your computer and use it in GitHub Desktop.
Save kosaki/fe1fd0739618857150a4 to your computer and use it in GitHub Desktop.
start: 0 0
uid: 0 0
uid: 0 0
ret: 1000 1000
uid: 1000 1000
uid: 1000 1000
uid: 1000 1000
uid: 1000 1000
uid: 1000 1000
uid: 1000 1000
uid: 1000 1000
#include <sys/types.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void* func(void* arg)
{
while(1){
printf("uid: %d %d\n", getuid(), geteuid());
sleep(1);
}
return NULL;
}
int main()
{
pthread_t thr;
int err;
printf("start: %d %d\n",getuid(), geteuid());
err = pthread_create(&thr, NULL, func, NULL);
sleep(1);
err = setuid(1000);
if (err != 0)
perror("setuid"), exit(1);
printf("ret: %d %d\n",getuid(), geteuid());
pause();
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment