Linux Ordinary users modify owner non-personal files why successful

Source: Internet
Author: User

Keyword: error: E45 has set the option ' ReadOnly ' (please add! Enforcement)

Linux to file and directory has good rights management, but today encountered a more strange thing, ordinary users of the file permissions are not writable, but can be forced to save the file, so there is a problem, other users can modify others files, this does not meet common sense and security requirements, for a moment do not understand the reason. Later, the combination of directory permissions, finally made clear the problem. The records are as follows:

1 Initial permissions for files and directories are as follows

Owner is root, other users have no write permission

Touch010  9: Test.txt

Directory permissions are as follows:

2 User user  6  5: Desktop
2 Edit and save the file using user Test.txt

Read the file's modification time before editing

[Email protected] Desktop]$ls-al--full- TimeTotal Dosage4drwxr-xr-x.2User User +  -- ,- the Ten: at:22.936290484+0800. drwx------. +User User4096  -- ,- the Ten: at:22.936290484+0800 ..-rw-r--r--.1Root root0  -- ,- the Ten: +:20.418438557+0800Test.txt

When you edit save, you are prompted as follows:

Use command: wq! , can also be successfully saved!! As follows:

VIcat  test.txt readonly to save

And look at the file modification time.

The time before the file was modified
Drwxr-xr-x.2User User +  -- ,- the Ten: at:22.936290484+0800. drwx------. +User User4096  -- ,- the Ten: at:22.936290484+0800 ..-rw-r--r--.1Root root0  -- ,- the Ten: +:20.418438557+0800test.txt[[email protected] Desktop]$VItest.txt [[email protected] Desktop]$Cattest.txt readonly to save
The time after the file was modified
[[email protected] Desktop]$ls-al--full- TimeTotal Dosage8drwxr-xr-x.2User User +  -- ,- the Ten: the:29.529216286+0800. drwx------. +User User4096  -- ,- the Ten: the:29.529216286+0800 ..-rw-r--r--.1User User -  -- ,- the Ten: the:29.497216306+0800test.txt[[email protected] Desktop]$

3 Cause Analysis

User users have no write permission on the file Test.txt, but can modify, and then look at the permissions of the directory of the file, the user has write permission.

The modified time of the modified Test.txt file is combined with the following:

Users did not modify the Test.txt, but first forcibly deleted the old Test.txt file (because user has write permission to the directory),

The Test.txt file is then re-created. What about the analysis, right? Look at the properties of the file before and after modifying it:

 before the change, the file owner and group were root,root[[email protected] Desktop]$ls-L--full- Time-rw-r--r--.1Root root0  -- ,- the Ten: +:20.418438557+0800test.txt Modified, the file owner and group have all become user, and the file change owner and group must be operated by root or Rootgroup member, so it is clear that the new file replaced the old file, the command is similar to MV Permissions have been modified. [[email protected] Desktop]$ls-L--full- Time-rw-r--r--.1User User -  -- ,- the Ten: the:29.497216306+0800Test.txt

Note: error: E45 has set the option ' ReadOnly ' (please add! Enforcement)

Linux Ordinary users modify owner non-personal files why successful

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.