Skip to content

Instantly share code, notes, and snippets.

@yinyin
Created December 7, 2009 15:37
Show Gist options
  • Save yinyin/250873 to your computer and use it in GitHub Desktop.
Save yinyin/250873 to your computer and use it in GitHub Desktop.
#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