Which permission for a directory when CGI code creates subdir?

63 Views Asked by At

In a CGI script, I execute a system call to make a directory, namely mkdir $dir. The parent directory under which this new directory is being created has a permission of 755. It doesn't allow me to create the directory unless the permission is 777. I am the owner of this directory, why do I need to set the permission to 777? This is on Google Cloud Compute.

1

There are 1 best solutions below

11
ikegami On

In order to create a file in a directory, you need permission to write to the directory.

With 755, only the owner of the directory can write the directory.

With 777, any user can write the the directory.

This tells us that the user as which the process executes isn't the same as the user that owns the directory.

If the user was the same, 700 would suffice.

If the user was different, but the group was the same, 770 would suffice.