requer autenticação para todas as alterações nesse arquivo (mesmo como root)
Tenho a sensação de que isso não é possível. Definitivamente não completamente à prova d'água. O superusuário é Deus no sistema.
Para monitorar um arquivo ou pasta, você pode usar o seguinte comando:
sudo apt-get install auditd # if not already installed
sudo auditctl -w <path_to_file> -p w -k <filter_key>
sudo ausearch -k <filter_key>
Exemplo:
$ sudo auditctl -w /etc -p w -k etc
$ sudo touch /etc/test
$ sudo ausearch -k etc
----
time->Tue Apr 21 15:40:36 2015
type=CONFIG_CHANGE msg=audit(1429623636.816:8542): auid=4294967295 ses=4294967295 op="add_rule" key="etc" list=4 res=1
----
time->Tue Apr 21 15:40:45 2015
type=PROCTITLE msg=audit(1429623645.648:8547): proctitle=746F756368002F6574632F74657374
type=PATH msg=audit(1429623645.648:8547): item=1 name="/etc/test" inode=136296 dev=08:01 mode=0100644 ouid=0 ogid=0 rdev=00:00 nametype=CREATE
type=PATH msg=audit(1429623645.648:8547): item=0 name="/etc/" inode=131073 dev=08:01 mode=040755 ouid=0 ogid=0 rdev=00:00 nametype=PARENT
type=CWD msg=audit(1429623645.648:8547): cwd="/"
type=SYSCALL msg=audit(1429623645.648:8547): arch=c000003e syscall=2 success=yes exit=3 a0=7ffd8f419d9d a1=941 a2=1b6 a3=691 items=2 ppid=7399 pid=7400 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=4294967295 comm="touch" exe="/bin/touch" key="etc"
de man auditctl
:
-p [r|w|x|a]
Describe the permission access type that a file system watch
will trigger on. r=read, w=write, x=execute, a=attribute change.
These permissions are not the standard file permissions, but
rather the kind of syscall that would do this kind of thing. The
read & write syscalls are omitted from this set since they would
overwhelm the logs. But rather for reads or writes, the open
flags are looked at to see what permission was requested.