For a linux-php file, you only need to have the read (r) Permission to execute the file in a special place of php or a cjava file.

Source: Internet
Author: User
Tags shebang
Only the read permission can normally execute the file (is it a boolean user performing this read file operation ?) Only the execution permission prompt is rejected (because php itself is not an execution file? Or is it an interpreted language ??) An error is reported if you have read execution permission.

Only the read permission can normally execute the file (is it a boolean user performing this read file operation ?)

Only the execution permission prompt is rejected (because php itself is not an execution file? Or is it an interpreted language ??)

An error is reported if you have read execution permission.

Reply content:

Only the read permission can normally execute the file (is it a boolean user performing this read file operation ?)

Only the execution permission prompt is rejected (because php itself is not an execution file? Or is it an interpreted language ??)

An error is reported if you have read execution permission.

The complexity of the operating system's management of file permissions far exceeds our imagination. The classic three-digit permission is not a reliable reason for permission judgment. Example:

  • The ACL permission system can affect

  • mountCommandnoexecCan interfere with the permissions of the entire mount point.

  • The permission mechanism of the operating system may be supplemented and expanded in the future (this is actually the most terrible)

I put it bluntly:"File with/without RWX" is easy for you to see. It cannot constitute a condition for "whether you have read, write, or execute permissions.

In fact, for a user program, it is impossible to determine whether a file can be read, written, or executed in advance. The only way for us to program is to "Try it"-simply execute the operation without any prior judgment, and say it again when an error occurs.

At this time, if the execution permission is determined, it is very dangerous: the php interpreter attempts to execute the file. If the execution succeeds, the execution of the file will inevitably occur and is inevitable. This means that the php interpreter can execute any file with execution right, even if it is not php code.

In this way, if the system is hacked and an unknown file is implanted, we will lose the last layer of protection for the php interpreter. Hackers can use the php interpreter, arbitrary execution of all malicious programs written in any language. The consequences will be devastating.

Therefore, "Only the read permission is required to call the php Command to execute the script.

In short: the interpreter in any language only requires the operating system to tryReadCode file to get the code text. After obtaining the code text, the interpreter will be responsible for subsequent work without the need for operating system dyeing. The relationship between the interpreter and the code is like the relationship between the editor and the document. The interpreter will never delegate to the Operating SystemRunAny file.

This is also true for java. The interpreters of all interpreted languages are like this, without any exceptions-no in the past, no in the present, and no in the future.

The problem lies in your execution method:

# Use a php file to read the content of the test. php file. $ php-f test. php $ which php/usr/bin/php./test. php # directly execute the test. php file.

TwiceInconsistent process subjects;

When shell executes an interpreted language script, it first searches for the shebang line in the file header,Process file content according to the interpreter specified by shebangIf this line does not exist, the bash interpretation script is used by default;

$ Cat x. php #! /Usr/bin/php <-this row is shebang
  $. /X. php # anyone with an x file can call this method directly and process the content according to the shebang interpreter. hello # If shebang is not available, you must use the interpreter (php) explicitly call $ php-f x. php # It doesn't matter whether shebang exists or not, just set x. the php file is read and passed to the php interpreter. Therefore, the file must have the r permission. hello $

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.