Forum Moderators: coopster

Message Too Old, No Replies

File protection setting

Wanna create the username and group setting when creating files

         

stefan009

6:50 am on Aug 17, 2004 (gmt 0)

10+ Year Member



Hi;

When creating text files in php the file has a username and group setting showing up on my server. (username- nobody group 99)

This is different to the username and group settings on files created in ftp. i.e. directly on the server. (where my login settings are used)

So I have to set chmod 0777 on my php created files that I want to edit later in ftp...

Anyone know how I can create the username and group setting on new files in php, so they are all the same?

Warboss Alex

7:16 am on Aug 17, 2004 (gmt 0)

10+ Year Member



You'd have to set those when you create the files, surely. You could make some sort of generic function which creates the files and then chmods them, so all you have to do is ..

<?php create_file('text.txt', '777');?> or something similar.

stefan009

8:06 am on Aug 17, 2004 (gmt 0)

10+ Year Member



Hi;

Yes the files are chmod with 775 - thats the prob!

Anyone know how I can create the username and group setting on new files so I don't have to chmod 777 instead?

Regards, Steve

stefan009

8:16 am on Aug 17, 2004 (gmt 0)

10+ Year Member



Hi;

Just to clarify: these are the file attributes showing up on my server:

file name-> myFile.htm
type-> HTML file
size-> 17422
owner-> nobody
group-> 99
permissions -> rw-r--r--
mod time-> Jun 15 12:50
=============================

It's the owner & group entries above that I was hoping I could specifyt in a php script....

Cheers!

UDaMan

8:29 am on Aug 17, 2004 (gmt 0)

10+ Year Member



[google.com...]

py9jmas

10:45 am on Aug 17, 2004 (gmt 0)

10+ Year Member



From the chown manual page on my FreeBSD system:
The ownership of a file may only be altered by a super-user for obvious security reasons.

PHP is running as part of the Apache process, therefore running as user nobody in your case. It is unpriviledged. It can only create files as the user it is running as, ie nobody.
FTP creates files as your user since you have logged into the FTP server as your username. The FTP server will be running as root so has the priviledges needed to set the user of the FTP login session to you.

stefan009

12:08 pm on Aug 17, 2004 (gmt 0)

10+ Year Member



Thanks,

..using a reseller a/c and I assumed I was a super-user! it looks like the problem is that I am *not* because I cannot modify files on my server that are php-created with an chmod other than 0777 even through cPanel by the look of it.

So I can't get at a clients files (other than to read them) if he needs help - thought there may be a way around it.

Best regards, Steve.

Birdman

3:00 pm on Aug 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe you can the PHP FTP functions [us3.php.net] to do what you want.