For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > November 2005 > rename(old file, new file) function Permission Denied









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author rename(old file, new file) function Permission Denied
chris

2005-11-17, 6:56 pm

im trying to rename a file using the rename(old file, new file) function

i have also tried the copy funtion also

the folder that the files are in are chmod 755
and the files themself are chmod 644

if i run the script on my own domain it works as expected

however i am trying to run it on another domain on another server, the files
and directory have the same permissions as mentioned above but i get a PHP
Permission denied warning.

my domain is running php 5.
the problem domain is running PHP 4.3.11

any idea why this is not working


Berimor

2005-11-17, 6:56 pm

On Thu, 17 Nov 2005 23:57:58 +0800, chris <someone@here.com> wrote:

> im trying to rename a file using the rename(old file, new file) function
>
> i have also tried the copy funtion also
>
> the folder that the files are in are chmod 755
> and the files themself are chmod 644
>
> if i run the script on my own domain it works as expected
>
> however i am trying to run it on another domain on another server, the
> files
> and directory have the same permissions as mentioned above but i get a
> PHP
> Permission denied warning.
>
> my domain is running php 5.
> the problem domain is running PHP 4.3.11
>
> any idea why this is not working
>




The problem is in apache + general system configuration. The PHP
interpretator by itself (or module - if installed as part of apache )
doesnt have enough rights to make such manipulations with file system. I
have some domains with the same problem and tech guys usually says - we
made this because of security reason. But i think that they are not
expirienced enough and are not sure - that's why cosiders this as the best
way to defend themselves from probable hacks.






--
Exact Meta Search | Major Search Engine
http://exactsearcher.com
Michael Vilain

2005-11-17, 9:55 pm

In article <ops0eo8y1or1c5ad@lancer>, Berimor <berimor@berimor.ber>
wrote:

> On Thu, 17 Nov 2005 23:57:58 +0800, chris <someone@here.com> wrote:
>
>
>
>
> The problem is in apache + general system configuration. The PHP
> interpretator by itself (or module - if installed as part of apache )
> doesnt have enough rights to make such manipulations with file system. I
> have some domains with the same problem and tech guys usually says - we
> made this because of security reason. But i think that they are not
> expirienced enough and are not sure - that's why cosiders this as the best
> way to defend themselves from probable hacks.


If the code that's doing the rename is running as an apache module
mod_php, then the process that's doing the rename is likely the Apache
process. It's probably running as nobody or www or apache. It may not
have write permissions to write into the directory where the newfile is
being placed.

To get around this, run php as a CGI script with the CGIwrap wrapper:

http://cgiwrap.sourceforge.net/

This will force the child process running the php code to run as a
specific user ID. It also requires that php be built as a command line
utility.

--
DeeDee, don't press that button! DeeDee! NO! Dee...



chris

2005-11-18, 3:55 am

unfortunatly i dont have root access to install any other modules

--
¼á
"Michael Vilain" <vilain@spamcop.net> wrote in message
news:vilain-7228F7.18154317112005@comcast.dca.giganews.com...
> In article <ops0eo8y1or1c5ad@lancer>, Berimor <berimor@berimor.ber>
> wrote:
>
>
> If the code that's doing the rename is running as an apache module
> mod_php, then the process that's doing the rename is likely the Apache
> process. It's probably running as nobody or www or apache. It may not
> have write permissions to write into the directory where the newfile is
> being placed.
>
> To get around this, run php as a CGI script with the CGIwrap wrapper:
>
> http://cgiwrap.sourceforge.net/
>
> This will force the child process running the php code to run as a
> specific user ID. It also requires that php be built as a command line
> utility.
>
> --
> DeeDee, don't press that button! DeeDee! NO! Dee...
>
>
>



Michael Vilain

2005-11-18, 7:55 am

In article <437d7159$1@dnews.tpgi.com.au>, "chris" <someone@here.com>
wrote:
[color=darkred]
> unfortunatly i dont have root access to install any other modules
>
> --
> ¼á
> "Michael Vilain" <vilain@spamcop.net> wrote in message
> news:vilain-7228F7.18154317112005@comcast.dca.giganews.com...

To get around this problem, you need root access to install CGIwrap or
you'll have to live with the restrictions of the code only running as it
is. If you can't get your job done on the existing server, either use
this as a reason to find another ISP or "go up the chain" to get root.

If you have physical access, you essentially have root. Otherwise,
start sending out your resume. You've been put in an impossible
position of having to do a job without the resources to accomplish it.

--
DeeDee, don't press that button! DeeDee! NO! Dee...



Etienne Marais

2005-11-18, 7:55 am

> If the code that's doing the rename is running as an apache module
> mod_php, then the process that's doing the rename is likely the Apache
> process. It's probably running as nobody or www or apache. It may not
> have write permissions to write into the directory where the newfile is
> being placed.


Could you not perhaps ask the service provider to add you (your account id)
to the same group as to which nobody/www/apache belongs to (apache in
specific usually belong to group apache) then chmod g+w the
files/directories which need to be overwriteable/renamed/createble.

Etienne Marais

chris

2005-11-22, 3:55 am



--
¼á
"Etienne Marais" <etienne@cosmiclink.co.za> wrote in message
news:dlkfpn$bne$1@ctb-nnrp2.saix.net...
>
> Could you not perhaps ask the service provider to add you (your account
> id)
> to the same group as to which nobody/www/apache belongs to (apache in
> specific usually belong to group apache) then chmod g+w the
> files/directories which need to be overwriteable/renamed/createble.
>
> Etienne Marais
>


i hav check with the service provider and they have SUExec installed on the
server, correct me if i am wrong, this should enable me to create or append
to files using fopen()


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com