Search code examples
linuxraspberry-piraspbianrm

Remove file with write group permission


I'm using Raspbian Stretch Lite and I followed an official tutorial from RapberryPi.org to set up Pure-FTPd. So now I have a virtual user that can create files through FTP owned by ftpuser:ftpgroup. I also add pi user in ftpgroup with following command :

usermod -a -G ftpgroup pi

But when I try to delete a file created by ftpuser it says

Operation not permitted

Here is a copy of my console :

pi@raspberry(rw):/var/ftp$ ls -la
total 4
drwxrwxrwt  2 root    root       60 Jun 20 15:58 .
drwxr-xr-x 11 root    root     4096 May  7 17:04 ..
-rwxrwxrwx 1 ftpuser ftpgroup 0 Jun 20 16:03 test
pi@raspberry(rw):/var/ftp$ whoami
pi
pi@raspberry(rw):/var/ftp$ grep -i --color 'ftpgroup' /etc/group
ftpgroup:x:1001:pi
pi@raspberry(rw):/var/ftp$ rm test
rm: cannot remove 'test': Operation not permitted

I don't understand why I can't remove test file if I'm in the ftpgroup and group has write permission.


Solution

  • You need write permissions om the directory as well. You change the TOC.

    To illustrate this:

    [ronald@lion tmp]$ ls -la
    total 0
    drwxr-xr-x. 2 root   root    19 Jun 20 15:48 .
    drwx------. 6 ronald ronald 195 Jun 20 15:48 ..
    -rw-r--r--. 1 ronald ronald   0 Jun 20 15:48 hallo
    [ronald@lion tmp]$ rm hallo
    rm: cannot remove ‘hallo’: Permission denied
    [ronald@lion tmp]$ id
    uid=1000(ronald) gid=1000(ronald) groups=1000(ronald) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
    [ronald@lion tmp]$ su
    Password: 
    [root@lion tmp]# chmod 777 .
    [root@lion tmp]# exit
    [ronald@lion tmp]$ ls -la
    total 0
    drwxrwxrwx. 2 root   root    19 Jun 20 15:48 .
    drwx------. 6 ronald ronald 195 Jun 20 15:48 ..
    -rw-r--r--. 1 ronald ronald   0 Jun 20 15:48 hallo
    [ronald@lion tmp]$ rm hallo
    [ronald@lion tmp]$