Linux System command PHP method of executing system commands

Source: Internet
Author: User
The code is as follows:

Copy the Code code as follows:


#include
#include
#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%s\n", strcat (Cmd,argv[1]));
Exit (0);
printf ("Uid:%un. Eudi=%un\n ", Getuid (), Geteuid ());
if (Setreuid (EUID,UID))
Perror ("Setreuid");
printf ("Uid:%un. Eudi=%un\n ", Getuid (), Geteuid ());
System (strcat (cmd,argv[1));
return 0;
}


Now, under Linux, GCC compiles, as well as the problem of the right to restoration:
Perform
Gcc-wall-o Phpchmod PHPCHMOD.C
Perform
chmod u+s./phpchmod
Use of PHP code:

Copy the Code code as follows:


$chmod _line = dirname (__file__). " /phpchmod./dest_dir/";
System ($chmod _line);

The above describes the Linux System command PHP to execute system commands, including the Linux system command content, I hope the PHP tutorial interested in a friend to help.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.