Summary
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":"127.0.0.1","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\ngithub.com/mattermost/mattermost-server/v5/config.(*FileStore).Load\n\tgithub.com/mattermost/mattermost-server/v5/config/file.go:160\ngithub.com/mattermost/mattermost-server/v5/config.(*FileStore).startWatcher.func1\n\tgithub.com/mattermost/mattermost-server/v5/config/file.go:247\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
…