When I change permissions for other or user on a setgid directory, the directory loses its setgid. How do I make the change without loosing it? sudo is not an option. Is it possible?
Here is some context.
$ whoami
webmin
$ groups
webmin
$ echo $SHELL
/bin/bash
$ uname -srvm
Linux 2.6.38-12-server #51-Ubuntu SMP Wed Sep 28 16:07:08 UTC 2011 x86_64
Here is an example.
$ ls -la
drwxr-s--- 4 webmin www-data 4096 2011-11-03 10:59 .
drwxr-s--- 4 webmin www-data 4096 2011-10-26 15:53 ..
$ mkdir libraries
$ ls -ld libraries
drwxr-sr-x 2 webmin www-data 4096 2011-11-03 11:01 libraries
$ chmod o= libraries
$ ls -ld libraries
drwxr-x--- 2 webmin www-data 4096 2011-11-03 11:01 libraries
^
`- The problem
The same happens if I modify the user's permissions on the directory.
The following fails too.
$ chmod g=rxs,o= libraries
=== UPDATE ====
Kevin's answer led me to what I believe is the cause of the problem. Apparently, you must be a member of the group assigned to the file. For example
$ whoami
webmin
$ groups
webmin www-data <---- Now we are in the www-data group.
$ mkdir t
$ ls -ld t
drwxr-sr-x 2 webmin www-data 4096 2011-11-03 12:03 t
$ chmod o= t
$ ls -ld t
drwxr-s--- 2 webmin www-data 4096 2011-11-03 12:03 t
^
`- Yeah!
So is the answer is "yes" as long as you are a member of the group, otherwise "no"?