The code is as follows:
Copy code The code is as follows:
#include
#include < stdlib.h>
#include
#include
#include
int main(int argc ,char * argv[])
{
uid_t uid,euid;
char cmd[1024]="chmod -R 777 ";
uid =getuid();
euid = geteuid ();
//printf("param %sn",strcat(cmd,argv[1]));
//exit(0);
//printf( "uid:%un. eudi=%unn",getuid(),geteuid());
if(setreuid(euid,uid))
perror("setreuid");
//printf("uid:%un. eudi=%unn",getuid(),geteuid());
system(strcat(cmd,argv[1]));
return 0;
}
Now let’s talk about gcc compilation and restoration of rights under Linux:
Execute
gcc -Wall -o phpchmod phpchmod.c
Execute
chmod u+s ./phpchmod
Use of php code:
Copy code The code is as follows:
$chmod_line = dirname(__FILE__)."/phpchmod ./dest_dir/";
system($chmod_line);
http://www.bkjia.com/PHPjc/320313.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320313.htmlTechArticleThe code is as follows: Copy the code as follows: #include stdio.h #include stdlib.h #include sys/types. h #include unistd.h #include string.h int main(int argc,char * argv[]) { uid_t uid,e...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn