Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong permissions sets sticky bit

A few days ago, I happened to set the permissions wrongly when using the php-function mkdir like this:

mkdir("foldername", 777, true);

The correct way is, asuming you want those kind of permissions:

mkdir("foldername", 0777, true);

I know that I shouldn't use 777 on my files or folders but this is for a very closed system, so please don't get stuck on that. Because here comes the funny(weird) part, at least, for me. Because we noted that something was very strange when this script created folders. The persmissions that gets set is really strange, especially for a non-power-user of linux like me. Because what we see is that the permissions of the created folders gets set to this:

d r - - - - x - - t

Which to me is strange, I hadn't heard about the sticky bit before (the t) but that is apparently set when you want to make that file only removable by root. Does anyone know why PHP behaves like this, or if it even is a PHP issue (not really an issue, since I'm then one using the function wrongly), or is this something that our *nix system does by default when in doubt or something?

like image 703
Daniel Figueroa Avatar asked Mar 13 '13 09:03

Daniel Figueroa


1 Answers

The file permissions are in octal notation (base 8).

777 is decimal there and it means 01411 octal which sets the sticky one too...

like image 146
Volkan Avatar answered Oct 26 '22 17:10

Volkan