Forum Moderators: bakedjake

Message Too Old, No Replies

chmod 2750 - what's that?

And can I do it via ftp?

         

louponne

3:24 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have just set up a new site on a new host. On this site, we have a php script that uploads photos for a "news" page. I was told by a techy at the host that in order to set the permissions right on the image folder, they had to be set to 2750. I've never heard of a four-digit chmod command before. What is this and can I do it via ftp?

ukgimp

3:26 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



set it to 750?

py9jmas

3:42 pm on Aug 23, 2004 (gmt 0)

10+ Year Member



man chmod(1):
Modes may be absolute or symbolic. An absolute mode is an octal number constructed from the sum of one or more of the following values:
.....
2000 (the setgid bit). Executable files with this bit set will run with effective gid set to the gid of the file owner.

Setgid on a directory may depend on what flavour of Unix you're using. Usually it sets the group of new files created in that directory to the group of the directory (instead of the user's primary group).

For FreeBSD:
[freebsd.org...]

drbrain

3:45 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The leftmost permission sets special permissions on the file.

For a file, a 2 in the leftmost position makes a binary execute setgid (as the group id of the file), a 4 in the leftmost position makes a binary execute setuid (as the group id of the file), and a 1 in the leftmost position sets the sticky flag.

So a file with mode 2750 is -rwxr-s---

Yes, ftp's chmod should allow you to setgid a file.

See also the chmod(1) manpage.

bnhall

3:51 pm on Aug 23, 2004 (gmt 0)

10+ Year Member



Yeah - this doesn't make sense. 2750 would be 4+2+1, 4+1, 0, ie permissions of -rwxr-x---. Doesn't this mean user all can't even read the file? The leading 2 - 2750 - means the setguid - set group userid - bit - is on. So this must mean user all gets setguid'd to the group owner of the file - and has read and execute (r-x) privileges. Why not just do chmod 755, ie -rwxr-xr-x? Seems simpler. And no, you can't do this via ftp, gotta use an ssh interface and login to the account.

drbrain

4:09 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No you can do this with ftp's chmod. ftp's chmod is the same chmod you use on the command line on a UNIX system. Same for ls and anything else in ftp's /bin.

You don't want other to view the contents of the directory.

You *especially* don't want to set the other execute bit for binaries, except for special utilities like sudo. Easy priviledge escalation there if a flaw is ever found.

louponne

4:11 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



wow, thanks for the quick replies! :)

Why not just do chmod 755, ie -rwxr-xr-x? Seems simpler.

Well, I chmod'ed the directory to 777 to check, but it didn't work.

Some of you say that I can do this via ftp, some that I can't -? I'm using WSFTP and in any case, can not find where I'd set this left-most digit.

drbrain

4:29 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't set it to 777, this lets anybody else on the system dump whatever they want into the directory.

Use the command line ftp, not a GUI:

Start -> Run

Type in "ftp.exe"

You'll get a DOS box with an ftp> prompt

open <the.hostname.example.com>

Then your user and password.

Type "help", if you see "chmod" then you have chmod ability on the server via ftp. If not you'll have to ask the server admin to either enable it, or you'll have to use a shell to do it.

If you see chmod,

cd /to/the/right/path

chmod 2750 your_directory

louponne

5:27 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, drbrain

using ftp.exe I can log in, but when I type "help" I do not see chmod.

On the other hand, I can chmod using WSFTP -?

louponne

6:51 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hm, I'm not sure that was very clear.

I can access the site via ftp.exe, but if I type "help", chmod is not among the choices there.

If I use WSFTP, I can chmod, via a menu uption, but I can't see how to do it via a typed-in command where I might be able to chmod 2750.

drbrain

10:40 pm on Aug 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Depending on what ftp server is being run, you may not be able to set the setgid bit. If you can't figure out how to do this, you should contact your hosting provider for assistance.