Use of symbolic links produce errors

Using symbolic links results in failure to read errors

Steps to reproduce
Version: 5.29.0

Following the Linux FHS standard, Mattermost has been installed in /opt with symbolic links to the configuration in /etc/opt/mattermost and state in /var/opt/mattermost.

For example in the /opt/mattermost/mattermost directory …

$ ls -l config logs
lrwxrwxrwx. 1 mattermost mattermost 30 Apr 22 21:01 config -> /etc/opt/mattermost/mattermost
lrwxrwxrwx. 1 mattermost mattermost 35 Apr 22 21:01 logs -> /var/opt/mattermost/mattermost/logs

Expected behavior
Mattermost is able to read the content in the respective locations

Observed behavior
Mattermost report errors about unable to read location. For example …

{"level":"error","ts":1619226957.4993267,"caller":"mlog/log.go:229","msg":"Error reading log file.","path":"/chat/api/v4/logs","request_id":"7hz6k8gtu78iddqqttyr9krg1e","ip_addr":"","user_id":"iue9gor1u78ixed4efyify1oxh","method":"GET","err_where":"","http_code":500,"err_details":"seek /opt/mattermost/mattermost/logs/mattermost.log: invalid argument"}

However, the file can be read from the operating system …

$ sudo -u mattermost cat /opt/mattermost/mattermost/logs/mattermost.log

Similarly, consider modifying the configuration located in /etc/opt/mattermost/mattermost/config.json. The following error is produced

{"level":"error","ts":1619228162.203506,"caller":"config/file.go:248","msg":"failed to reload file on change","path":"/opt/mattermost/mattermost/config/config.json","error":"failed to open /opt/mattermost/mattermost/config/config.json for reading: open /opt/mattermost/mattermost/config/config.json: permission denied","errorVerbose":"open /opt/mattermost/mattermost/config/config.json: permission denied\nfailed to open /opt/mattermost/mattermost/config/config.json for reading\*FileStore).Load\n\\*FileStore).startWatcher.func1\n\\nruntime.goexit\n\truntime/asm_amd64.s:1373"}

This file can also be read by the mattermost user

$ sudo -u mattermost cat /etc/opt/mattermost/mattermost/config.json

I would suggest changing the file permissions of the location of the files themselves, at their location specified /var/opt/mattermost and make sure to change ownership to mattermost as well. You may be encountering an issue with file permissions here that is preventing it from being read.

You should be able to do this by running the command sudo chmod +rwx /var/opt/mattermost/* and sudo chown mattermost:mattermost -r /var/opt/mattermost/

I hope it helps!

1 Like