I created user small
, added him to group kek
and allowed that group to only read files in user home directory. Then I chowned all files to root:kek
.
However, small
still can delete files in his home directory.
Commands I ran:
useradd -ms /bin/bash small
groupadd kek
usermod -a -G kek small
chown -R root:kek /home/small/*
chmod -R g=r /home/small/*
Then when I try to remove file:
$ ls -l
total 16
-rw-r--r-- 1 root kek 240 Jun 23 06:17 Dockerfile
-rw-r--r-- 1 root kek 39 Jun 21 09:17 flag.txt
-rw-r--r-- 1 root kek 2336 Jun 22 14:19 server.py
-rw-r--r-- 1 root kek 24 Jun 22 08:16 small.py
$ rm flag.txt
$ ls -l
total 12
-rw-r--r-- 1 root kek 240 Jun 23 06:17 Dockerfile
-rw-r--r-- 1 root kek 2336 Jun 22 14:19 server.py
-rw-r--r-- 1 root kek 24 Jun 22 08:16 small.py
$ whoami
small
Why does this happens?
/home/small/server
, put all files there andchown
andchmod
the same way as before. Nowsmall
cannot chdir to that directory even though groupkek
has read permission, why? – nikrom3000 Jun 23 '18 at 06:40cd
into a directory, the user must have execute permissions on it. Read permissions only gives you the ability to list files. – Kusalananda Jun 23 '18 at 07:06