Koozali.org: home of the SME Server

[SOLVED] Symlinks to another ibay with http/ftp and php

Offline _YO_

  • ***
  • 45
  • +0/-0
[SOLVED] Symlinks to another ibay with http/ftp and php
« on: February 22, 2008, 07:40:24 PM »
Hi to all,

On a SME7.3 server, i've to manage a symlink between 2 bays.

The first one called "photo" without CGI,PHP,SSI activated (only a share on my LAN)
The second one called "test" with CGI,PHP,SSI activated. I've made some php for LAN use.
On this second bay, i create e symlink "toPhoto" to acces files on "photo" bay

From SSH console as root user this symlink works great.
I've autorised symlinks to work under http. Adding FollowSymlinks property to enabled to the "test" bay. And using browser it works (i can acces toPhoto and finally "photo" bay files)

Now the problem : to explain a little example
Code: [Select]
<?php
function rapport($path){
if ( is_dir($path) )
echo ($path.' dir<br>');
else
echo ($path.' NOT dir<br>');
if (is_readable($path))
  echo ($path.' readable<br>');
else
  echo ($path.' NOT readable<br>');
if (is_link($path))
  echo ($path.' link <br>');
else
  echo ($path.' NOT link <br>');
}

$prefix='.';
rapport($prefix.'/toPhoto');&#160; &#160; &#160; &#160; &#160; // the symlink
rapport($prefix.'/toPhoto/');
rapport($prefix.'/toPhoto/.');
rapport($prefix.'/photoTMP');&#160; &#160; &#160; &#160; // a real directory

?>

and this give :

./toPhoto NOT dir
./toPhoto NOT readable
./toPhoto NOT link
./toPhoto/ NOT dir
./toPhoto/ NOT readable
./toPhoto/ NOT link
./toPhoto/. NOT dir
./toPhoto/. NOT readable
./toPhoto/. NOT link
./photoTMP dir
./photoTMP readable
./photoTMP NOT link

Could you explain me why PHP (without any error) tell me that toPhoto is not a link nor a directory ?
« Last Edit: February 23, 2008, 03:43:06 PM by _YO_ »
.YO.

Offline _YO_

  • ***
  • 45
  • +0/-0
Re: Symlinks to another ibay with http/ftp and php
« Reply #1 on: February 23, 2008, 08:43:42 AM »
When changing symlink toPhoto to the ./photoTmp local dir gives this  :shock: :
./toPhoto dir
./toPhoto readable
./toPhoto link
./toPhoto/ dir
./toPhoto/ readable
./toPhoto/ NOT link
./toPhoto/. dir
./toPhoto/. readable
./toPhoto/. NOT link
./photoTMP dir
./photoTMP readable
./photoTMP NOT link


 :???: So it should be a right problem.
I have not rights from on bay to access another !
How to do this now !!!
.YO.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: Symlinks to another ibay with http/ftp and php
« Reply #2 on: February 23, 2008, 08:55:59 AM »
When changing symlink toPhoto to the ./photoTmp local dir gives this  :shock: :
./toPhoto dir
./toPhoto readable
./toPhoto link
./toPhoto/ dir
./toPhoto/ readable
./toPhoto/ NOT link
./toPhoto/. dir
./toPhoto/. readable
./toPhoto/. NOT link
./photoTMP dir
./photoTMP readable
./photoTMP NOT link

I do not think these are the error messages, next time post exact error messages so we do not need to guess, for clues you could best look at the webserver log files at the time you had the problem, /var/log/httpd/access_log and /var/log/httpd/error_log should show you exactly what the error would be.

:???: So it should be a right problem.
I have not rights from on bay to access another !
How to do this now !!!
There are a few things you need to check:
  • Does the ibay configuration directive in your webserver configuration file have the following set?
    +Options FollowSymLinks
    But I doubt you need the symlink, if you just set the access rights on both ibays properly you should not need the symlink
  • On top off that you are most likely suffering from the PhpBaseDir restriction. This prevents php from looking in to other directories outside the configuration tree, see the wiki how to modify things as you should be able to access another ibay without creating a symlink with a little work.
  • A third option would be to loose the second ibay all together and just store the photos in a subdirectory in your ibay, this should work out of the box.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline _YO_

  • ***
  • 45
  • +0/-0
Re: Symlinks to another ibay with http/ftp and php
« Reply #3 on: February 23, 2008, 09:16:36 AM »
Thanks for you help cactus

Quote from: cactus
I do not think these are the error messages, next time post exact error messages so we do not need to guess, for clues you could best look at the webserver log files at the time you had the problem, /var/log/httpd/access_log and /var/log/httpd/error_log should show you exactly what the error would be.
I've no errors in that files
Only that in access log (tst.php is the script of the 1st post)
ouvrie.inet 192.168.0.197 - - [23/Feb/2008:09:05:13 +0100] "GET /test/gal/tst.php HTTP/1.1" 200 266 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)"

Quote from: cactus
Does the ibay configuration directive in your webserver configuration file have the following set?
+Options FollowSymLinks
But I doubt you need the symlink, if you just set the access rights on both ibays properly you should not need the symlink
Yes it's done
[root@router photo]# db accounts show test
test=ibay
    CgiBin=enabled
    FollowSymLinks=enabled
    Gid=5010
    Group=shared
    Name=pour essai
    PasswordSet=no
    PublicAccess=local
    Uid=5010
    UserAccess=wr-group-rd-everyone

giving this in httpd.conf
#------------------------------------------------------------
# test ibay directories (pour essai)
#------------------------------------------------------------

<Directory /home/e-smith/files/ibays/test/html>
    Options None
    Options +Indexes
    Options +FollowSymLinks
    Options +Includes
    AllowOverride None
    order deny,allow
    deny from all
    allow from 127.0.0.1 192.168.0.0/255.255.255.0
</Directory>



Sorry for now... no time to answer the next points. Post a reply later.

Quote from: cactus
On top off that you are most likely suffering from the PhpBaseDir restriction. This prevents php from looking in to other directories outside the configuration tree, see the wiki how to modify things as you should be able to access another ibay without creating a symlink with a little work.
Quote from: cactus
A third option would be to loose the second ibay all together and just store the photos in a subdirectory in your ibay, this should work out of the box.
.YO.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: Symlinks to another ibay with http/ftp and php
« Reply #4 on: February 23, 2008, 09:26:24 AM »
Thanks for you help cactus
I've no errors in that files
Only that in access log (tst.php is the script of the 1st post)
ouvrie.inet 192.168.0.197 - - [23/Feb/2008:09:05:13 +0100] "GET /test/gal/tst.php HTTP/1.1" 200 266 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)"
That might be because you do not do proper error handling, but enough to not have php throw errors to you.
What does the web server log say when you try and follow the symlink in a webbrowser?
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline _YO_

  • ***
  • 45
  • +0/-0
Re: Symlinks to another ibay with http/ftp and php
« Reply #5 on: February 23, 2008, 02:39:38 PM »
Quote from: cactus
That might be because you do not do proper error handling, but enough to not have php throw errors to you.
No i don't think so. Cause when i've a buggy PHP, errors appears in /var/log/messages
Feb 23 13:43:14 router httpd: PHP Parse error:  parse error, unexpected T_STRING in /home/e-smith/files/ibays/test/html/gal/tst.php on line 19

Quote from: cactus
What does the web server log say when you try and follow the symlink in a webbrowser?
Nothing in error_log
Nothing in messages
Browsing files in bay photo/files (that's OK using http but PHP do not acces to this)
and finally : this in access_log
ouvrie.inet 192.168.0.197 - - [23/Feb/2008:13:28:34 +0100] "GET /test/gal/toPhoto/ HTTP/1.1" 200 1311 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)"
ouvrie.inet 192.168.0.197 - - [23/Feb/2008:13:28:34 +0100] "GET /icons/blank.gif HTTP/1.1" 200 148 "http://router/test/gal/toPhoto/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)"
ouvrie.inet 192.168.0.197 - - [23/Feb/2008:13:28:34 +0100] "GET /icons/back.gif HTTP/1.1" 200 216 "http://router/test/gal/toPhoto/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)"
ouvrie.inet 192.168.0.197 - - [23/Feb/2008:13:28:34 +0100] "GET /icons/folder.gif HTTP/1.1" 200 225 "http://router/test/gal/toPhoto/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)"
ouvrie.inet 192.168.0.197 - - [23/Feb/2008:13:28:34 +0100] "GET /icons/image2.gif HTTP/1.1" 200 309 "http://router/test/gal/toPhoto/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)"


The last 2 points :
Quote from: cactus
A third option would be to loose the second ibay all together and just store the photos in a subdirectory in your ibay, this should work out of the box.
i would avoid this cause of one directory level that appears in the network share when you grant public web access or anonymous FTP to local network
Quote from: cactus
On top off that you are most likely suffering from the PhpBaseDir restriction. This prevents php from looking in to other directories outside the configuration tree, see the wiki how to modify things as you should be able to access another ibay without creating a symlink with a little work.
Yes. A good way to dig. I'd an error using PHP symlink function
Feb 22 18:19:55 router httpd: PHP Warning:  symlink(): File exists in /home/e-smith/files/ibays/test/html/gal/tst.php on line 42
But using is_dir or is_link no error...
.YO.

Offline _YO_

  • ***
  • 45
  • +0/-0
[SOLVED] Symlinks to another ibay with http/ftp and php
« Reply #6 on: February 23, 2008, 02:57:58 PM »
That's it cactus !

It's an openbasedir problem :

db accounts setprop test PHPBaseDir /home/e-smith/files/ibays/test/:/home/e-smith/files/ibays/photo/files/
signal-event ibay-modifiy test


That solves the problem.

Really great thanks cactus for your time to help me.

              .YO.
« Last Edit: February 23, 2008, 03:00:37 PM by _YO_ »
.YO.