openSUSE / mirrorbrain

MirrorBrain
http://mirrorbrain.org/
Other
26 stars 17 forks source link

mod_mirrorbrain does not handle filename correctly if inside of symlinked dir #23

Open lrupp opened 4 years ago

lrupp commented 4 years ago

From https://github.com/poeml/mirrorbrain/issues/173 (might be fixed already)

Let's assume we have the following standard httpd setup with mirrorbrain activated:

DocumentRoot /var/www/htdocs/
FollowSymlinks yes

Inside of that directory we place a symlink pointing to a directory with longer path: /var/www/htdocs/mysymlink -> /mnt/www/somelongdir/someotherdir/

We place file "foo.txt" in that folder and try to wget that from the webserver.

The following will happen:

This results in an invalid lookup path, giving a strange error log:

[Fri Dec 22 14:21:54.376008 2017] [mirrorbrain:notice] [pid 6000:tid 140026726733568] [client xx.xx.xx.xx:34122] [mod_mirrorbrain] 'ngdir/someotherdir/mysymlink/foo.txt': no usable mirrors after classification. Have to deliver directly.

The problem ist here in mod_mirrorbrain.c:

/* the leading directory needs to be stripped from the file path /
/ a directory from Apache always ends in '/'; a result from realpath() doesn't */
filename = realfile + strlen(mirror_base) + 1;

This does not care about symlinks.


darix commented on 24 Mar

JFYI: If you dont object, I will pull this fix into gh:openSUSE/mirrorbrain. (which is our fork with all the fixes and features we did over the last few years)