Created
July 28, 2014 16:56
-
-
Save kosaki/fe1fd0739618857150a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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