3

I'm creating directories and changing the permissions of them in perl with the following code:

umask 0000;
mkdir $path, 0770;
chown $userid, $groupid, $path;

Now when I do ls -l on a directory I've just created, they are as follows:

drwxrws---  2 user group 4096 Nov  3 15:34 test1

I notice for the group permissions, there's an s instead of x. Even if I chmod manually to remove all permissions for the user and group ("chmod g=" and "chmod u=", it's still there:

d-----S---  2 user group 4096 Nov  3 15:36 test2

The internet suggests S means everything in the folder is run as su or something? I don't quite understand what it means but I figure I should understand seeing as these are webroots so if there's a security implication, I ought to be aware of it.

Many thanks for your help!

4
  • This is not a programming question, thus it is off-topic.
    – Oded
    Nov 3, 2012 at 16:21
  • I did wonder. Which site do you suggest it should go instead? I was thinking serverfault but then I figure it's not really a sysadmin question either
    – penguin
    Nov 3, 2012 at 16:22
  • unix?
    – Oded
    Nov 3, 2012 at 16:22
  • Look at the footer - all non-beta sites are listed.
    – Oded
    Nov 3, 2012 at 16:31

3 Answers 3

7

s means the setgid/setuid bit and the executable bit both are set

S means only the setgid/setuid bit is set

check out man chmod for more information.

2

This is happening because of the umask value you're setting.

The internet suggests S means everything in the folder is run as su or something?

That is incorrect.

If the setuid bit is set on an executable program, then it will execute with the privileges of its owner.

If the setgid bit is set on the executable program, then it will execute with the permissions of its group.

So, don't go around creating things as root:root with umask 0000.

Better yet, don't ever set that to your umask.

See here: http://linuxzoo.net/page/sec_umask.html

The number given as a parameter to the umask command works in a opposite manner to the number given to the chmod command. The 'mask' serves to remove permissions as opposed to granting them.

0

In a way, it indicates an "error":

There is no point in setting the setuid bit, if the executable bit is not set.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .