views:

75

answers:

2

I have a php script:

$extract_dir = "./";
$extract_file = "extractME.zip";

$zip = new ZipArchive;
$res = $zip->open($extract_file);
if ($res === TRUE) {
    $zip->extractTo($extract_dir);
    $zip->close();
    echo "ok";
} else {
    echo "failed";
}

But when I execute this script, via http://www.mywebsite.com/extract.php

All the files on FTP are show with OWNER 'root', but not the user ex . 'neo' as it should be. So the user cant edit/rename/delete these files.

Is it possible to fix this anyhow (I own the server), that files will be extracted with 'USERNAME' OWNERSHIP ?

Thanks for any help. I'm stuck with this.

A: 

It extract as the user running the webserver (note: you should not be running it as root). Try using chown.

Maerlyn
chown DOESN'T work, becouse chown only possible to root server user. And I don't want give access to any user(even MASTER USER) to login VIA root. And chown doesn't work with user level. So it probably the server configuration problem. I often run a "chown -R usrNAME:usrNAME /home/usrNAME/public_html/*" but this is WRONG solution
ozzWANTED
@ozzwanted That is not what I meant. I am suggesting to chown the files after you've extracted them - that is why I linked php's chown command. And it *is* possible, since your webserver is running as root.
Maerlyn
+1  A: 

ozzwanted, for some reason your web server (apache) is running as root so any file it makes will be made as root. This should never be the case. apache usually runs as 'www-data' or 'httpd', or 'nobody' or 'god' depending on the linux distro.

I suggest you look into this from a sysadmin point of view and have someone sort it out for you before you end up getting exploited. (assuming this is a live server)

You can use www.php.net/chown function or your can run a 'chown' command on the command line or do it from PHP with something like system() or exec() functions.

Good luck.

Paul Dragoonis