LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Apache 2.2.17 + CIFS + symlinks = error (https://www.linuxquestions.org/questions/linux-newbie-8/apache-2-2-17-cifs-symlinks-%3D-error-875789/)

fmillion 04-19-2011 12:17 AM

Apache 2.2.17 + CIFS + symlinks = error
 
Hello,

I have an LFS system with the latest Apache. Everything on the system is working properly. I have however noticed a very strange and annoying problem with Apache.

I would like to serve some documents off an XP system. I mounted the XP system on /mnt/xp. There are other things I want access to on the XP system, so the documents to serve on the web are located at /mnt/xp/webdocs.

I created a symlink in my Apache DocumentRoot to point to /mnt/xp/webdocs. (e.g. /home/www/htdocs/docs -> /mnt/xp/webdocs)

Upon trying to access this link (http://www.mysite.com/docs) I get the following in error_log

Code:

[Mon Apr 18 23:52:42 2011] [error] [client 192.168.1.165] Symbolic link not allowed or link target not accessible: /home/www/htdocs/docs
I already have FollowSymLinks set for my entire site in the Directory section. I also have EnableSendfile off to prevent some known problems with kernel caching and file sending from CIFS shares.

The odd part of this is:

1. If I create a symlink to somewhere on the local filesystem (e.g. /home/www/htdocs/link -> /bin) I can see everything in /bin in a listing and access it. This means that FollowSymlinks isn't the problem.

2. If I create a symlink to somewhere outside the CIFS share, and then FROM THAT POINT navigate into the share, it works. (e.g. /home/www/htdocs/link -> /mnt, and then http://www.mysite.com/link/xp/webdocs). This shows it's not an issue of httpd not being able to access the content. Obviously doing it this way is a HUGE security hole and opens up all sorts of other issues.

3. The problem only occurs if I am trying to access a symlink that points to somewhere inside a CIFS share.

Has anyone observed this behavior/know what's causing it? Is there anything I can do to fix it?

My "temporary" fix was to create a second share on the XP box and mount it directly under /home/www/htdocs/docs. This works, but it's not preferable at all, as in some other projects I'm working on it may not be as predictable where the content will be located on the Windows machine.

As a side note, this used to work fine in Apache 2.0.x...

Thanks!

FM

zjoske 04-21-2011 03:43 AM

Hi fmillion

- Did you check the access properties for the file/tree on your windows box?
- Did you verify whether /mnt/xp/webdocs is mounted (hard/soft/automount mounted) on /home/www/htdocs/docs and that it is readable/writeable,for the webserver too?

Jos

fmillion 04-21-2011 07:50 PM

Hello zjoske, thanks for your reply.

The problem definitely appears to be with Apache's resolving of symlinks that point directly into a CIFS mounted filesystem. I used Sudo to run a Bash shell under the apache user and was able to freely access the files. The mount is explicit and I verified it.

As I said in my original post, the part that leads me to believe this is a symlink resolution bug is that if I mount the cifs filesystem inside the apache htdocs folder, it works. It is only if I attempt to symlink to a cifs filesystem. Just to test this, I tried mounting the cifs filesystem inside the htdocs folder then symlinking into it from there, and it still failed. (e.g. I mounted the xp share on /home/www/htdocs/xp and went to site.com/xp and saw the content, then I made a symlink like /home/www/htdocs/xplink -> ./xp and another like /home/www/htdocs/xpdocs -> ./xp/docs and then accessing site.com/xplink and site.com/xpdocs and both failed.)

Thanks, if anyone has further advice, please post.

FM

golumn 06-03-2013 04:20 PM

Work Around
 
I ran into an almost identical problem on Ubuntu(Precise) running Apache 2.2. I could not find the source of the problem but I was able to create a work around. Instead of symlinking to the mounted directory I bound the new directory to the mounted directory using mount -B olddir newdir.

Hope it helps.

speeves 10-07-2014 03:39 PM

mount -B worked for me.

sudo mount -B /mnt/courses ~/mnt_courses

Thanks for the tip!


All times are GMT -5. The time now is 08:01 AM.