Announcement

#1 2020-08-23 20:21:34

Aevaris
Member
2020-08-23
13

[resolved] Symlink trouble

Hi all,

I've been googling this awhile and found several similar threads, but I'm not sure my problem is the same as those.

I have some photos maintained in a different directory and tried making a symlink to just the photo as well as to the directory and neither get found by piwigo. I know the symlink is good as I can access the symlink via my browser directly.

For example, I have photos in /volume2/my/photos/mydir. I have piwigo located at /volume2/web/piwigo. My symlink from piwigo/galleries/mysymdir to /volume2/my/photos/mydir displays fine if I ls in it and i can display images from it at my website of mysite/piwigo/galleries/mysymdir/myphoto.png.

This implies that my symlink is good, my configuration is good, but something either configuration or functionally wrong with piwigo.

Is there something I missed?

Piwigo version:
PHP version:
MySQL version:
Piwigo URL: http://

Offline

 

#2 2020-08-23 21:11:40

erAck
Only trying to help
2015-09-06
1998

Re: [resolved] Symlink trouble

You forgot the FTP sync step after having created the symlink.


Running Piwigo at https://erack.net/gallery/

Offline

 

#3 2020-08-24 00:11:45

Aevaris
Member
2020-08-23
13

Re: [resolved] Symlink trouble

Hi erAck,

It says nothing found when I try to sync. It finds the folder if I link only the file and it finds nothing if I link the directory. Is there a step I missed in the synchronization activity?

My test image is fine on web view:
https://imgur.com/rVUfPZ6

Is a symlink:
https://imgur.com/ISfFixF

But doesn't index:
https://imgur.com/NKkjuN0

Offline

 

#4 2020-08-24 10:43:03

erAck
Only trying to help
2015-09-06
1998

Re: [resolved] Symlink trouble

It doesn't help if you paste links to images as images..


Running Piwigo at https://erack.net/gallery/

Offline

 

#5 2020-08-25 02:32:35

Aevaris
Member
2020-08-23
13

Re: [resolved] Symlink trouble

What information are you looking for? Here are some non-image screens:

MyUser@MyServer:/volume2/web/STLView/galleries$ ls -l
total 16
lrwxrwxrwx 1 MyUser users   95 Aug 23 12:59 Almiraj -> /volume2/Loot/Media/3D Printing/3D Print Files/Miniatures/D&D minis/Creatures/Beasts/A/Almiraj/
drwxrwxrwx 2 MyUser users 4096 Aug 23 17:10 Almiraj2
-rwxrwxr-x 1 http    http   610 Aug 22 13:40 index.php
drwxrwxrwx 2 MyUser users 4096 Aug 23 23:05 Test

MyUser@MyServer:/volume2/web/STLView/galleries$ cd Almiraj
MyUser@MyServer:/volume2/web/STLView/galleries/Almiraj$ ls -l
total 21728
-rwxrwxrwx+ 1 MyUser users  1748768 Aug 14  2018 Almiraj.blend
-rwxrwxrwx+ 1 MyUser users  1748768 Aug 14  2018 Almiraj.blend1
-rwxrwxrwx+ 1 MyUser users 14096174 Nov 14  2019 Almiraj.photon
-rwxrwxrwx  1 MyUser users   152491 Jan  4  2020 Almiraj.PNG
-rwxrwxrwx+ 1 MyUser  users  4495484 Aug 14  2018 Almiraj.stl

Almiraj.PNG is accessible here:
**linkHS**

But indexing doesn't find it.

Offline

 

#6 2020-08-25 12:05:56

erAck
Only trying to help
2015-09-06
1998

Re: [resolved] Symlink trouble

Was the Almiraj directory added (maybe in an earlier run) as category name to the database's piwigo_categories table?
If it was, what's its status (public/private)?
And the visible attribute (true/false)?

If the directory was not added as category and the directory structure lives on some NAS or Samba disk then double check the permissions for the web server user if it is allowed to traverse all directories.

It might also be that at some point the full directory realpath
/volume2/Loot/Media/3D Printing/3D Print Files/Miniatures/D&D minis/Creatures/Beasts/A/Almiraj/
containing spaces and the & character gets in the way (though only names starting from the linked name should be affected by that, but I'm not sure). See also the mentioned FTP sync docs. Then try if adding those characters to the local config's (local/config/config.inc.php or use [extension by Piwigo Team] LocalFiles Editor) sync_chars_regex helps

$conf['sync_chars_regex'] = '/^[a-zA-Z0-9-_. &]+$/';

or if not renaming and replacing those characters with _ underscore in the path would help.


Running Piwigo at https://erack.net/gallery/

Offline

 

#7 2020-08-27 04:17:13

Aevaris
Member
2020-08-23
13

Re: [resolved] Symlink trouble

Making those updates didn't help.

I've been trying a few things and in my testing found this probably isnt directly a symlink problem but a security problem. Synology appears to have locked down symlinks out of the webroot directory pretty hard and I can't find where that's controlled. My symlink to something inside the web root worked fine.

I tried updating php.ini with open_basedir, I tried updating my apache conf, tried updated my httpd conf, the UI PHP updater doesnt seem to do anything. So I'm still digging into where its controlling it, but it definitely is rejecting access to anything outside.

I tried switch to nginx which lets my display symlinked files instead of the 403 i get with apache, but the piwigo indexer still doesnt find anything for them.

I'll report back if I learn anything interesting.

Last edited by Aevaris (2020-08-27 04:18:18)

Offline

 

#8 2020-08-27 05:38:04

Aevaris
Member
2020-08-23
13

Re: [resolved] Symlink trouble

To confirm this is somewhere related to linking outside of the root, I tested this.

1. Symlink (no spaces, no characters) outside of webroot:
lrwxrwxrwx+ 1 http http   49 Aug 25 22:43 Abolethian3.png -> /volume2/Loot/Media/Episodic/zTest/Abolethian.png

2. Symlink (no space, no characters) inside webroot:
lrwxrwxrwx+ 1 http http     41 Aug 26 22:25 Abolethian4.png -> /volume2/web/STLView/Test/Abolethian4.png

Both can be found via web view:
**linkHS**

Piwigo index finds #2 but does not find #1. When my backend is Apache, it throws 403s on outside webroot symlinks, even with a crazy open_basedir of "/".

Offline

 

#9 2020-08-28 06:45:31

Aevaris
Member
2020-08-23
13

Re: [resolved] Symlink trouble

Ok, so I gave up. Instead, I decided to make a bind mount and that fixed my problem.

I could not, for the life of me, figure out why I could access my file as a website and not as a symlink via piwigo synchronization with nginx or not even access it over the web via apache (403). I started ripping out security to the point I wasn't comfortable.

This gives me fairly solid protection with the -r option to make it read only while also treating this directory basically like a local directory since the filesystem presents this as a d not an l.

I'm going to next reinstall my webserver and piwigo before promoting it to formal production though because I don't actually remember what I ripped out security wise lol.

Thanks for your thoughts and findings. Hopefully this helps others either with a synology or otherwise.

Details:
mount --bind -r "/volume2/Loot/Media/Episodic/zTest" "/volume2/web/STLView/galleries/Almiraj2"

MyUser@MyServer:/volume2/web/STLView/galleries$ ls -l
drwxrwxrwx+ 2 MyUser users 4096 Aug 27 23:28 Almiraj2

MyUser@MyServer:/volume2/web/STLView/galleries/Almiraj2$ ls -l
total 4604
-rwxrwxrwx+ 1 MyUser users  215415 Aug 24 21:11 Abolethian5.png
-rwxrwxrwx+ 1 MyUser users 4495484 Aug 23 13:28 Almiraj.stl

MyUser@MyServer:/volume2/Loot/Media/Episodic/zTest2$ ls -l
total 4604
-rwxrwxrwx+ 1 MyUser users  215415 Aug 24 21:11 Abolethian5.png
-rwxrwxrwx+ 1 MyUser users 4495484 Aug 23 13:28 Almiraj.stl

[./galleries/Almiraj2/Abolethian5.png] added

Last edited by Aevaris (2020-08-28 06:46:21)

Offline

 

#10 2020-08-28 10:43:56

erAck
Only trying to help
2015-09-06
1998

Re: [resolved] Symlink trouble

Thanks for updating and providing the solution!


Running Piwigo at https://erack.net/gallery/

Offline

 

#11 2022-05-11 06:00:23

MrThiemann
Member
2022-05-11
1

Re: [resolved] Symlink trouble

I hope I can answer this in a simple way...

I also have the problem that I can't get any pictures in my gallery...

i downloaded my entire google database
these are now in the directory: /root/gphotos-sync/photos/
my piwigo-gallerie is in: /var/www/html/piwigo/galleries/

i created a symlink with:

Code:

ln -s /root/gphotos-sync/photos/ /var/www/html/piwigo/galleries/

it took me a few days to get any further... i think it was a problem with the rights

this morning I then set a chmod 755 to "root" (this is absolutely fatal, but my piwigo gallery is only accessible locally at the moment)

when i use ls -la in /var/www/html/piwigo/galleries

Code:

root@Apache:/var/www/html/piwigo/galleries# ls -la
total 20
drwxr-xr-x  3 root root 4096 May 11 03:09 .
drwxr-xr-x 16 root root 4096 May 10 13:36 ..
-rw-r--r--  1 root root   15 May 10 14:33 .htaccess
drwxr-xr-x  9 root root 4096 May 11 03:39 google
-rw-r--r--  1 root root  610 Jan  1 19:26 index.php
lrwxrwxrwx  1 root root   26 May 10 19:23 photos -> /root/gphotos-sync/photos/
root@Apache:/var/www/html/piwigo/galleries#

an "namei -m" outputs the following:

Code:

root@Apache:/var/www/html/piwigo/galleries# namei -m /root/gphotos-sync/photos/
f: /root/gphotos-sync/photos/
 drwxr-xr-x /
 drwxr-xr-x root
 drwxr-xr-x gphotos-sync
 drwxr-xr-x photos
root@Apache:/var/www/html/piwigo/galleries#

with chmod i finally managed to get the files listed.
i can also access the google images via the browser via the direct path.

Code:

root@Apache:~/gphotos-sync/photos# ls
2016  2017  2018  2019  2020  2021  2022
root@Apache:~/gphotos-sync/photos# cd 2022/
root@Apache:~/gphotos-sync/photos/2022# ls
01  02  03  04  05
root@Apache:~/gphotos-sync/photos/2022# cd 05/
root@Apache:~/gphotos-sync/photos/2022/05# ls
0938A500-FD07-4B6D-8BEC-FC4255BC7D77.jpg  IMG_0573.PNG            IMG_0611.HEIC  IMG_0651.MOV   IMG_0686.PNG   IMG_0726.HEIC
219E3BB9-153C-4F75-AEF9-736F049892B0.jpg  IMG_0574.HEIC           IMG_0612.HEIC  IMG_0652.MOV   IMG_0687.PNG   IMG_0727.HEIC
33EEB2E9-10A9-45BA-B0B1-798BED8C101F.jpg  IMG_0575-CINEMATIC.mp4  IMG_0613.HEIC  IMG_0653.MOV   IMG_0688.PNG   IMG_0728.HEIC
493340BF-4E98-49DE-974F-FF4D72FEDCD7.jpg  IMG_0575.HEIC           IMG_0614.PNG   IMG_0654.HEIC  IMG_0689.PNG   IMG_0729.HEIC
...... ...... ...... ...... ...... ......

it looks exactly like this in the browser

However, no images are added to the database via synchronizing.
I only see the directories.
So the years (2022, 2021, 2020, .....)
and there the months (12,11,10.....)
But like I said, no pictures.

Now I really don't know what else to do?
I would be happy if you could help me with this!


- - - - -

I have one more question...

I also mounted my directory like above in the code...
How can I undo this?

Last edited by MrThiemann (2022-05-11 06:50:30)

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact