Php uses sudo to obtain ifconfigeth0down permission solution

Source: Internet
Author: User
Php has obtained the ifconfigeth0down permission through sudo. I have already opened many posts, but I really can't achieve it. I hope you can give me some advice, even if it is materials. if phpsudo gets the permission, it's really unreliable on the oknet. ------ solution -------------------- I am like this: after sudogeditetcsudoers is modified, you do not need to enter the sudo password. php uses sudo to obtain the ifconfig eth0 down permission.
I have already opened many posts, but I really can't achieve it. I hope you can give me some advice, even if it's materials. If php sudo has the permission, it's really unreliable on the Internet.

------ Solution --------------------
I am like this: after sudo gedit/etc/sudoers is modified, the sudo password is not required.
Http://jingyan.baidu.com/article/495ba84135a16738b30eded1.html
------ Solution --------------------
The answer is

1. create a file, such as pw.txt, to save your root password. for example, the password is 1234.
Remember that only 1234 of the file content is needed

2. php file content
Shell_exec ('sudo-u root-S ifconfig eth0 down <./pw.txt ');

Disable Nic normally
------ Solution --------------------
As you have done, isn't the user protection of the operating system actually a false one?

Put the operations you need into the shell file and execute them in the waiting process or scheduled task.
Check whether there is a start signal first. if not, do not run it.
Generally, the startup signal can be used as a file and can be written by php in web mode.

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.