Topic: Use chmod in install.php

I was looking at this

    // Check if the cache directory is writable
    if (!@is_writable('./cache/'))
        $alerts .= '<p style="font-size: 1.1em"><span style="color: #C03000"><strong>The cache directory is currently not writable!</strong></span> In order for PunBB to function properly, the directory named <em>cache</em> must be writable by PHP. Use chmod to set the appropriate directory permissions. If in doubt, chmod to 0777.</p>';

    // Check if default avatar directory is writable
    if (!@is_writable('./img/avatars/'))
        $alerts .= '<p style="font-size: 1.1em"><span style="color: #C03000"><strong>The avatar directory is currently not writable!</strong></span> If you want users to be able to upload their own avatar images you must see to it that the directory named <em>img/avatars</em> is writable by PHP. You can later choose to save avatar images in a different directory (see Admin/Options). Use chmod to set the appropriate directory permissions. If in doubt, chmod to 0777.</p>';

I'm not sure if it makes sense, but I think the code should look more like this (replace 0777 with the appropriate number, I haven't used chmod before wink )

    // Lets try using chmod, just in case
    @chmod('./cache/', 0777);
    @chmod('./img/avatars/', 0777);
    
    // Check if the cache directory is writable
    if (!@is_writable('./cache/'))
        $alerts .= '<p style="font-size: 1.1em"><span style="color: #C03000"><strong>The cache directory is currently not writable!</strong></span> In order for PunBB to function properly, the directory named <em>cache</em> must be writable by PHP. Use chmod to set the appropriate directory permissions. If in doubt, chmod to 0777.</p>';

    // Check if default avatar directory is writable
    if (!@is_writable('./img/avatars/'))
        $alerts .= '<p style="font-size: 1.1em"><span style="color: #C03000"><strong>The avatar directory is currently not writable!</strong></span> If you want users to be able to upload their own avatar images you must see to it that the directory named <em>img/avatars</em> is writable by PHP. You can later choose to save avatar images in a different directory (see Admin/Options). Use chmod to set the appropriate directory permissions. If in doubt, chmod to 0777.</p>';

Re: Use chmod in install.php

Well, personally, I can't really see any reason why it couldn't. Does anyone have a different opinion?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Use chmod in install.php

A directory can be writable and yet not be a 777. It would not be nice to silently force a 777 chmod if it's not needed.

4 (edited by Tobi 2005-07-08 12:02)

Re: Use chmod in install.php

I think this does not make very much sense.

The script is run by the webserver.
The webserver is usually run as "www" or "nobody" and can only chmod files that it owns.

So, if the webserver already owns the directory it makes no sense chmoding it because nobody else will write in it.
If not the webserver will not be allowed to chmod it anyway.

No, sorry, I don't see the point. But maybe I'm just blind..,

The German PunBB Site:
PunBB-forum.de

Re: Use chmod in install.php

You're right smile

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Use chmod in install.php

Jérémie wrote:

A directory can be writable and yet not be a 777. It would not be nice to silently force a 777 chmod if it's not needed.

I wasn't suggesting using 777, I said to replace it with whatever it should actually be tongue

Tobi wrote:

I think this does not make very much sense.

The script is run by the webserver.
The webserver is usually run as "www" or "nobody" and can only chmod files that it owns.

So, if the webserver already owns the directory it makes no sense chmoding it because nobody else will write in it.
If not the webserver will not be allowed to chmod it anyway.

No, sorry, I don't see the point. But maybe I'm just blind..,

I had someone I know install PunBB, the folders were there but weren't writable by the webserver. I think you're right, that chmod didn't work for him, but in that case isn't mkdir for those folders a good idea?

7

Re: Use chmod in install.php

Smartys wrote:

I had someone I know install PunBB, the folders were there but weren't writable by the webserver. I think you're right, that chmod didn't work for him, but in that case isn't mkdir for those folders a good idea?

No, don't think so, because if the web server wants to do a mkdir() then the directory where it wants do this must be world writable as well.
I mean if your layout is like this
myboardroot    user    group      drwx-r-x-r-x
Then the apache running as "nobody" can not do a mkdir() inside this directory.

And we don't want that, do we? cool

I really think the way it is done now is the best possible.

The German PunBB Site:
PunBB-forum.de