setgid bit always unset when changing file permissions

2

2

good evening dear Serverfolks!

i am a newbi so do not bear with me! I run a linux sever that is administered by a friend of me. He prepares the chown and permissins - with the setgit-bit to on.

Well the trouble is that i get lost the setgitbit every time when i touch the permissions with FileZilla. That is the terrible issue! Note - at the moment i do not have a access to the server wit WinSCP - winscp can set the Setgit. Filezilla cannot do this at all!

on openSuse Linux server My Setup: OpenSuse 11.4 on the local machine! Linux- Server

FileZilla Client
----------------
Version:          3.3.4.1
Build information:
  Compiled for:   i686-pc-linux-gnu
  Compiled on:    i686-pc-linux-gnu
  Build date:     2011-02-23
  Compiled with:  gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
  Compiler flags: -fomit-frame-pointer -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector 
- funwind-tables -fasynchronous-unwind-tables -g -fstack-protector -Wall -g -fexceptions

Linked against:
  wxWidgets:      2.8.11
  GnuTLS:         2.8.6

Operating system:
  Name:           Linux 2.6.37.6-0.7-default i686
  Version:        2.6

Well folks i go crazy - sure thing:

I run a linux-root-server that is administered by a friend of mine. i controll the SFTP session - with filezilla (see all i mentione above) in order to do installations and maintenance of some drupal-installations (and besides them some joomla-sites) Note: in the future i want to install Drush - in order to get rid all that annoying bugs.

I am using directories with setgid bit set. I want to change the permissions of newly created directories to give write permission to the group (by default they have not). For this I right-click on the directory and change the permissions from the Properties dialog. When I change the permissions of a directory that way, the setgid bit gets removed. In fact, there is no way to set the setgid bit, it just always gets turned off, whatever operation one does on permissions.I heard that a buddy found a workaround by creating a custom command that executes chmod -R g+w "!" and applies on directories. This works fine. he said. Well what should i do!?

Well i go almost crazy and throw the computer out of the window (well notabene - of the 14 th floor) this is sure thing no good idea but i need to have a solution. waht should i do here.

Note: with FileZilla you cannot (!!!!!) set the SETGID-Bit again - no way here - no chance. But with winscp (see below the link ). And you can imagine with Drush you can do it too! What sould i do - can you advice something for me! btw: see winscp with its ability to control the SETGID bit more than the FileZilla can do!! Well what can cause the issue - where is it rooted. Why do i loose the SETGID-Bit every time!

It is possible that our SFTP server does not support the setgit bit and silently ignores the request to set it.

What is the issue - can it be the SFTP.-SERVER!?

As i am a bloddy newbi i probably do not provide you with all the infos you need!? Do you need more information or more input!? Should i do more investigations on the troubles and the environment. just let me know - i do everything to get the troubles rid!

look forward to hear from you

Greetings zero

Update: hi Zoredache and malcompdx thx for the answers. Well Malcompdx - did you recognice a error in the server-subsytem!? Did you find the issue is rooted in this. Well the trouble is that i get lost the setgitbit every time when i touch the permissions! That is the terrible issue! And if i got you right - then the fix is in your answer Malcompdx - many thanks . also to you ZoreDache

btw see the thread that describes the same issue - that happens also in winscp http://winscp.net/forum/viewtopic.php?t=8306

zero

Posted 2012-01-26T19:36:13.100

Reputation: 291

Answers

2

It's not actually filezilla, it's the umask that sftp uses.

Change

Subsystem sftp /usr/libexec/openssh/sftp-server

to Subsystem sftp /bin/sh -c 'umask 0002; /usr/libexec/openssh/sftp-server'

in the server's sshd_config file, and restart sshd, and you should then find that sgid bit is preserved if the parent directory has it set.

malcolmpdx

Posted 2012-01-26T19:36:13.100

Reputation: 136

If it was the umask, then why would it work in winscp? – Zoredache – 2012-01-26T19:46:31.410

Because scp != sftp. They function entirely differently - scp respects the umask of the user that it is running as, but sftp doesn't. – malcolmpdx – 2012-01-26T19:56:16.723

hi Zoredache and malcompdx thx for the answers. Well Malcompdx - did you recognice a error in the server-subsytem!? Did you find the issue is rooted in this. Well the trouble is that i get lost the setgitbit every time when i touch the permissions! That is the terrible issue! And if i got you right - then the fix is in your answer Malcompdx - many thanks . also to you ZoreDache – zero – 2012-01-26T20:11:50.263

'UPDATE to explain it agian I run a linux sever that is administered by a friend of me. He prepares the chown and permissins - with the setgit-bit to on.

Well the trouble is that i get lost the setgitbit every time when i touch the permissions with FileZilla. That is the terrible issue! Note - at the moment i do not have a access to the server wit WinSCP - winscp can set the Setgit. Filezilla cannot do this at all! – zero – 2012-01-26T20:18:06.603

Malcompdx should i change the Subsystem sftp /usr/libexec/openssh/sftp-server to Subsystem sftp /bin/sh -c 'umask 0002; /usr/libexec/openssh/sftp-server'

in the server's sshd_config file, and restart sshd, and then it works!?! Should i then find that sgid bit is preserved if the parent directory has it set. Well Malcompdx i try it out and come back and report allthe findings – zero – 2012-01-26T20:19:45.410

@malcolmpdx, winscp, uses the sftp protocol by default these days, not scp, so I am not sure how your scp != sftp comment is relevant. – Zoredache – 2012-01-26T21:12:37.040

@Zoredache - I wasn't aware of that, thanks for letting me know. My comment was based on the assumption that winscp uses scp, which apparently is incorrect. What I do know from experience is that filezilla, at least, completely ignores the user's umask settings, so the above fix was necessary in my case. – malcolmpdx – 2012-01-26T21:28:51.567

Hello dear friends - i heard that the SSH can cause the issue Yes you are right, we were using a openssh 4.6 server, which is know to have this Bug ( https://bugzilla.mindrot.org/show_bug.cgi?id=1310 ). Using another openssh version 5.2 fixes the problem (apparently it has been fixed in 5.1). see here http://winscp.net/forum/viewtopic.php?t=8306&highlight=setgit well that seems to be another story - a bit different to malcommdx advices - but i is interesting too. ´well malcom and zoredache - thx to you both for the hints. i will try to do my best to fix the issues - greetings

– zero – 2012-01-27T13:42:15.873

1

The application is almost certainly sending the permission change to the server in octal like 0775.

Simply checking/unchecking boxes is not going to do what you want. If you want to set the permissions, provide the options in octal.

To set the permission so of a directory to drwxrwsr-x, you should send 2775 into the numeric value box.

filezilla permissions

Zoredache

Posted 2012-01-26T19:36:13.100

Reputation: 18 453

hi ZoreDache thx for the answer – zero – 2012-01-26T20:12:10.417

zoredache - my experience (with the above mentioned Filezilla ) is the following EVERYTIME i touch the file-permissions i loose the setgit bit. 'I can do whatever i want!? I get lost it! – zero – 2012-01-26T21:05:52.800