Created
December 7, 2009 15:37
-
-
Save yinyin/250873 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <unistd.h> | |
#include <stdio.h> | |
#define UID_ROOT (0) | |
#define PATH_KILLALL "/usr/bin/killall" | |
#define PROCNAME_TO_OPERATE "gcin" | |
int main(int argc, char ** argv) | |
{ | |
char * const ARG_ARRAY[3] = { | |
PATH_KILLALL, | |
PROCNAME_TO_OPERATE, | |
NULL | |
}; | |
if(0 != setuid(UID_ROOT)) | |
{ | |
perror("Cannot perform setuid() operation"); | |
return -1; | |
} | |
if(0 != execv(PATH_KILLALL, ARG_ARRAY)) | |
{ | |
perror("Failed on execv() operation"); | |
return -1; | |
} | |
fprintf(stderr, "Operation of execv() returned\n\n"); | |
return 0; | |
} | |
/* | |
vim: ts=4 sw=4 ai nowrap | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment