Create files with specified owner<

liunx

Guest
Hey guys. Long time no post :p

Anyway, I have today been working on a class to zip/unzip files on the server for a project I am helping with.

However, since the files are spawned by a server process when they are made (zip is made, or files extracted from one) the server gets ownership of the files and not my account, so I am unable to do anything to them afer they are made.

Is there anyway to get around that and have the files be created with my account having ownership of them?

I have already tried chown();, but as Im not a superuser it doesnt work for me.you could chmod 666 or 777Tried it already. Doesnt work.
I cant chmod them via the ftp client, only can I chmod them if I have the object that creates the files chmod them when it makes them (which it does).if you can't get to them with ftp then you can't chmod them with code.

if you control where they go then put them in a place you can get to them.I can get to them, I just cant delete them or chmod thwm with the ftp client.
when I try to delete:

COMMAND:>DELE /test/unzip_test/TC/111/curdir.php
550 Could not delete /test/unzip_test/TC/111/curdir.php: Permission denied
ERROR:> Requested action not taken (e.g., file or directory not found, no access).


when I try to chmod:

COMMAND:>SITE CHMOD 777 /test/unzip_test/TC/111/curdir.php
550 Could not change perms on /test/unzip_test/TC/111/curdir.php: Bad file descriptor
ERROR:> Requested action not taken (e.g., file or directory not found, no access).


I know the script that makes the files can chmod them, as at first they were chmod 644, and then I added code to chmod the files 755 when it makes them and the resulting files then had chmod of 755 instead of 644.ahh now we are getting somewhere.

in the file that chomds them you need to do it this way.


$oldmask = umask(0);
chmod ($path, 0777);
umask($oldmask);

that has worked for me when I get permissions denied.Didnt work, still gives me same error.
Im pretty sure its a problem with file owner, as they have owner as '99' and Im 32046 not 99in the script that zip/unzip, you need to chmod 777 so the webserver user will open up the file that are created for everybody (including you)!

it's normal that you can't chmod with ftp since you are not the owner of the file.

and 644 or 755 are no good because the flag for others (where you're in) are read-onlyOriginally posted by illogique

it's normal that you can't chmod with ftp since you are not the owner of the file.

and 644 or 755 are no good because the flag for others (where you're in) are read-only

Even when the script chmods the files 777, I still cant do anything to them :p as I had already said in reply to yuor previous post.

What I need to know, is how I can make them so that I am onwer of them.
and cant use chown(); cause im not super user.pretty strange that chmod doesn't work (maybe disable by your host?)

so maybe this workaround

1. get the list of the files to be created by the script
2. open a ftp connection with your username/password
3. create all the needed files
4. chmod the files so the webserver user can modify them
5. let the script modify the files
6. rechmod the files with the ftp connection.I can chmod files that I own.
And I had thought oF doing the ftp idea before, but it would be messy and I had really thought there was some other way in whicn I could get myself to be owner of the files.
 
Back
Top