Read Permission Missing for Mopidy Config (as service)

Hi - I’ve done a search on this forum and on google and I didn’t see an answer to my specific situation, so apologies if I missed it.

I just installed mopidy on my odroid c2 via dietpi. I am running mopidy as a service, and when I run sudo mopidyctl config instead of reading the default config, it gives me an error that says the read permission is missing from /etc/mopidy/mopidy.conf. See below for the full output. The conf that it lists below is not what I have in /etc/mopidy/mopidy.conf.

Running "/usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf config" as user mopidy
/usr/lib/python2.7/dist-packages/mopidy/ext.py:202: PkgResourcesDeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
  extension_class = entry_point.load(require=False)
WARNING  Loading config from /etc/mopidy/mopidy.conf failed; read permission missing
[core]
cache_dir = $XDG_CACHE_DIR/mopidy
config_dir = $XDG_CONFIG_DIR/mopidy
data_dir = $XDG_DATA_DIR/mopidy
max_tracklist_length = 10000
restore_state = false

[logging]
color = true
console_format = %(levelname)-8s %(message)s
debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n  %(message)s
debug_file = mopidy.log
config_file =

[audio]
mixer = software
mixer_volume =
output = autoaudiosink
buffer_time =

[proxy]
scheme =
hostname =
port =
username =
password =

[musicbox_webclient]
enabled = true
musicbox = false
websocket_host =
websocket_port =
on_track_click = PLAY_ALL

[local-images]
enabled = true
library = json
base_uri = /images/
image_dir =
album_art_files =
  *.jpg
  *.jpeg
  *.png

[mpd]
enabled = true
hostname = 127.0.0.1
port = 6600
password =
max_connections = 20
connection_timeout = 60
zeroconf = Mopidy MPD server on $hostname
command_blacklist =
  listall
  listallinfo
default_playlist_scheme = m3u

[http]
enabled = true
hostname = 127.0.0.1
port = 6680
static_dir =
zeroconf = Mopidy HTTP server on $hostname

[stream]
enabled = true
protocols =
  http
  https
  mms
  rtmp
  rtmps
  rtsp
metadata_blacklist =
timeout = 5000

[m3u]
enabled = true
base_dir =
default_encoding = latin-1
default_extension = .m3u8
playlists_dir =

[softwaremixer]
enabled = true

[file]
enabled = true
media_dirs =
  $XDG_MUSIC_DIR|Music
  ~/|Home
excluded_file_extensions =
  .jpg
  .jpeg
show_dotfiles = false
follow_symlinks = false
metadata_timeout = 1000

[local]
enabled = false  ; Extension disabled due to config errors.
library = json
media_dir =  ; Must be set.
scan_timeout = 1000
scan_flush_threshold = 100
scan_follow_symlinks = false
excluded_file_extensions =
  .directory
  .html
  .jpeg
  .jpg
  .log
  .nfo
  .png
  .txt

When I run ls -l /etc/ on /etc/, I get the following permissions for mopidy:
drwxr-xr-x 2 root root 4096 Dec 26 14:49 mopidy

and the same command within the mopidy folder:
-rw-r----- 1 root root 343 Dec 26 14:49 mopidy.conf

I’ve tried a few different things to get the mopidy.conf as read for the mopidy user, but my google skills are failing me, as everything I try is causing additional errors.

Any assistance would be GREATLY appreciated. Thank you

I think this is a question for the dietpi team.

I guess maybe it’ll help to say that the Mopidy service should run as the mopidy user and the service files must be readable by that user. This all works correctly In Debian, this is likely something non-standard in dietpi.

thanks for the feedback, I’ll post on their forums as well.

I think the read permission is supposed to be restricted because the configuration file can contain credentials for authenticating with sites like SoundCloud and Spotify. It’s better to not make those readable by everyone, though not absolutely required on a single user system. It ought to be owned by the mopidy user. You could do something like “sudo chown mopidy /etc/mopidy/mopidy.conf” to make it owned and therefore readable by the mopidy user. The chown command must be run as root, because a normal user doesn’t have access to do that.

If changing the permission of the conf file doesn’t work the following solved it (as well as being able to scan the local music source): running mopidy as root (correct me if this is not desirable) by changing mopidy to root in /usr/sbin/mopidyctl with the following setting

DAEMON_USER="root"

This is not a good idea on a regular Debian install. It’s a big hack and a security risk.

Dietpi might run everything as root (I think they used to, at least) in which case it doesn’t matter so much. This is a very specific case.

If you want to scan your music collection from a drive mounted as a different user and are having permission problems, running Mopidy as root is not the way to solve that on regular Debian/Raspbian systems.

1 Like

I concede I hadn’t read the previous comment by @dreamlayers carefully enough. I solved my problem as was suggested with:
sudo chown mopidy /etc/mopidy/mopidy.conf
My files in /home/debian/music-directory are finally accessible this time after:
sudo mopidyctl local scan
I appreciate you setting this on the right track. It was a mistake (now corrected) to have altered the file containing:
DAEMON_USER="mopidy"

For the record, I realized my trouble was because I had removed the contents of the original /etc/mopidy/mopidy.conf and replaced it with the entire ~/.config/mopidy/mopidy.conf when I moved to running Mopidy as a service. Later I slimmed down the config, but it was still missing the [core] and [logging] sections. Not too smart!

I reinstalled everything and configured the service for my system as per the docs

Now scanning and visualization both work fine without the permissions hacks.