首页 > 代码库 > linux实现改变命令的执行权限

linux实现改变命令的执行权限

******test.c*******

#include<stdio.h>

#include<stdlib.h>

#include<sys/types.h>

#include<unistd.h>

int main(int argc, char** argv)

{

  uid_t uid, euid;

  uid = getuid();

  euid = geteuid();

  if (setreuid(euid, uid)) perror("setreuid");

  system("command");

  return 0;

}

/***********************/

编译:gcc -o test -Wall test.c

root下:chmod u+s test

linux实现改变命令的执行权限