Thursday 25 April 2019

linux - Not able to write to directory despite correct permission and group


Have been strugling with a wordpress-virus attacking and Writing files in one of my sites. One strange thing i noticed is that even with the root user i am not able to write to the directory. The directory is 755. Trying to write to Another directory with same permissions works.


root@console:/var/www/clients/client3/web22# whoami
root

root@console:/var/www/clients/client3/web22# groups root
root : root

root@console:/var/www/clients/client3/web22# ls -alh
total 29M
drwxr-xr-x 8 root root 4.0K Sep 13 11:09 .
drwxr-xr-x 6 root root 4.0K Oct 5 15:04 ..
drwxr-xr-x 2 web22 client3 4.0K Feb 18 2016 cgi-bin
drwxr-xr-x 2 root root 4.0K Nov 2 2016 log
drwxr-x--x 7 web22 client3 4.0K Oct 5 14:54 web

root@console:/var/www/clients/client3/web22# touch test
touch: cannot touch ‘test’: Permission denied

root@console:/var/www/clients/client3/web22# mkdir test
mkdir: cannot create directory ‘test’: Permission denied

Heres a go on Another folder with same permissions, same user and same machine:


root@console:/var/www/clients/client5/web24# ls -lah
total 32K
drwxr-xr-x 8 root root 4.0K Oct 5 15:12 .
drwxr-xr-x 4 root root 4.0K Mar 24 2016 ..
drwxr-xr-x 2 web24 client5 4.0K Feb 19 2016 cgi-bin
drwxr-xr-x 2 root root 4.0K Nov 2 2016 log
drwxr-x--x 9 web24 client5 4.0K Mar 19 2016 web

root@console:/var/www/clients/client5/web24# touch test
root@console:/var/www/clients/client5/web24# rm test

Why am I not able to write anything to the folder /var/www/clients/client3/web22 and is there anything else than Groups and users that can deny write to a directory?


Edit - Adding necessary information:


root@console:/var/www/clients/client3/web22# cat /proc/version
Linux version 3.16.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03)

root@console:/var/www/clients/client3# lsattr
----i--------e-- ./web22
-------------e-- ./web13

root@console:/var/www/clients/client3# lsattr web22
-------------e-- web22/cgi-bin
-------------e-- web22/web
-------------e-- web22/log


root@console:/var/www/clients/client3# getfacl web22
# file: web22
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

root@console:/var/www/clients/client3# getfacl .
# file: .
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

Answer



The i in the attr list means that file has been marked as "immutable" so that's why you can't change it. You can remove that if you want with chattr -i .


From the man page for chattr:



A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.



No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...