First I know that use
vim to write a binary executable program is not recommended. So, I don't want to talk about its rationality here.
I have a binary program, with permission 755(owner is root), so as user
root, I expect the fact that I can write to it. The program is not running, with command
fuser, no output return, then I open it with
vi, and type
:wq to just write and quit, then
vi warns me that
E45: 'readonly' option is set (add ! to override). The problem is who set the
readonly option? The linux kernel?
Then I add a
!, which is
:wq! now, the program cannot run now, which is expected.
And the same file with the same permission on another machine with the same OS and kernel version. This time, I can write to it with
:wq, the magic here is that I can run the program at this machine, though the
md5sum gives different results.
The system is RHEL 6.4.
vi in fact is
EDIT: add some command output as @ctrl-alt-delor suggested.
[root@localhost x]# uname -r 2.6.32-422.214.171.124.ky3.1.x86_64 [root@localhost x]# whoami root [root@localhost x]# lsof XXX [root@localhost x]# fuser XXX [root@localhost x]# ls -l XXX -rwxr-xr-x. 1 root root 5178556 Apr 19 13:27 XXX [root@localhost x]# ls -la total 5080 drwxr-xr-x. 5 root root 4096 Apr 21 19:23 . drwxr-xr-x. 10 root root 4096 May 18 2018 .. -rwxr-xr-x. 1 root root 5178556 Apr 19 13:27 XXX drwxr-xr-x. 5 root root 4096 Apr 18 17:24 blabla drwxr-xr-x. 2 root root 4096 Apr 15 18:59 blabla2 drwxr-xr-x. 8 root root 4096 Apr 22 10:36 blabla3
EDIT: according to @Wildcard's comment.
[root@localhost x]# getfacl XXX # file: XXX # owner: root # group: root user::rwx group::r-x other::r-x [root@localhost x]# lsattr XXX -------------e- XXX
EDIT: add SELINUX info
[root@localhost x]# getenforce Permissive [root@localhost x]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=permissive # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@localhost x]# ls -Z XXX -rwxr-xr-x. root root unconfined_u:object_r:usr_t:s0 XXX