File owner/group 48/48

2019-07-29 09:54发布

问题:

I'm having a problem. In my PHP host when I create a file or dir (via rename() or mkdir()) my files are created with OWNER 48, GROUP 48, instead of FTP OWNER/GROUP (like other hosts).

The problem is that if I do a mkdir() for instance, via PHP, I can't manager this dir (like put some files in, rename dir or remove), even in PHP! If I create this dir via FTP I can do all. Really strange.

Now I need know: I'm wrong or my PHP Host is bugged? They told me that it's a code problem.

My code:

mkdir($image_dir, 0777, true);

It'll create on FTP something like that:

NAME   TYPE  DATE   PERMS      OWNER/GROUP
./1967 [DIR] [DATE] fle (0755) 48/48

Even I set chmod on mkdir() to 0777, it create like 0755.

So, I can do something, or my host need does?

Thanks!

回答1:

at first this is not strange, it's good that webserver/php are running as a different user than your ftp client.

well this is ugly but may help you: in php use umask(0000); before any file operations. it will try to make all files and directories 0777 when created by php.

you should check if webserver/php and ftp client are at least in the same group so you can use the umask 0007.

btw. does php run in safe mode? it could prevent making files writable to other users... anyway you should be sure to disable it as it's deprecated since php 5.3 and removed since 5.4