group permissions/webserver

Hi,

there is one strange situation with directory permissions that I run into every now and then, and now I face it a gain with a webserver.
Situation (example):

drwxrwsr-x 14 user www-data 4096 Jul 28 11:06 .
drwxr-xr-x 2 www-data www-data 4096 Jul 28 11:06 subdir
-rwxr-xr-x 1 www-data www-data 4096 Jul 28 11:06 subdir/file

Goal: remove or chown subdir/file without becoming root.

One could also make the top directory chgrp user, and then all files below it would be group user as well, but this does not seem to help, does it?
Thanks for a hint

To chown subdir/file you have to have write permissions on this file, so I think you cannot chown subdir/file.
To remove subdir/file you need write permissions on subdir. :frowning:

To avoid this in future remove SGID attribute on a '.' (current directory). If the SGID (Set Group Identification) attribute is set on a directory, files created in that directory inherit its group ownership. If the SGID is not set the file's group ownership corresponds to the user's default group.

ok, but what do I gain if all files/dirs are group "user"?

You can create files with your default group :slight_smile:
But this wont help you to delete that file. You must to edit permission mask to give you needed permissions on new files (I don't think you have permissions on that too :)) )