OK I finally got this working satisfactorily and I will detail the changes I made so that others can benefit from my struggle with it.
Firstly I thought I would try to get the server to run as user mike. I did try to change the line in the service file to have ProtectHome=read-only but when the daemon was running as user minidlna this still gave the same permissions errors when the media files were set to be directories in the /home area for user mike.
So after a number of changes the set of changes that finally worked for me is as follows:
The systemd unit file at /usr/lib/systemd/system/minidlna.service now contains the following:
$this->bbcode_second_pass_code('', '
[Unit]
Description=minidlna server
After=network.target
[Service]
Type=simple
User=mike
Group=mike
ExecStart=/usr/bin/minidlnad -S
ProtectSystem=full
ProtectHome=read-only
PrivateDevices=on
NoNewPrivileges=on
[Install]
WantedBy=multi-user.target
')
So this was set to run the daemon as user mike and also to change the default ProtectHome from "on" to "read-only" which is the suggestion for this parameter in the systemd directives descriptor at
http://www.freedesktop.org/software/sys ... .exec.htmlSecondly I changed the /etc/minidlna.conf file to have the user specified as "mike", and the media files within mike's /home/mike area and have read access to all.
So in /etc/minidlna,conf I have user=mike and also:
$this->bbcode_second_pass_code('', '
media_dir=A,/home/mike/Music/
media_dir=P,/home/mike/Pictures/
media_dir=V,/home/mike/Videos/
')
I also changed the log file definition to:
$this->bbcode_second_pass_code('', '
log_dir=/home/mike/.config/minidlna
')
Note that I did try to also change the db_dir=/home/mike/.config/cache/minidlna but that led to a failure to start the systemd unit so I reverted that line to:
$this->bbcode_second_pass_code('', '
db_dir=/var/cache/minidlna
')
Then I made sure that the ownership and permissions for the various key directories and files were set as:
$this->bbcode_second_pass_code('', '
[root@cubox1 ~]# ls -ld /var/cache/minidlna
drwxr-xr-x 3 mike mike 4096 Feb 27 15:12 /var/cache/minidlna
[root@cubox1 ~]# ls -l /var/cache/minidlna
total 716
drwxr-xr-x 3 mike mike 4096 Feb 27 15:12 art_cache
-rw-r--r-- 1 mike mike 729088 Feb 27 15:12 files.db
')
The pid file has permissions:
$this->bbcode_second_pass_code('', '
[root@cubox1 ~]# ls -ld /var/run/minidlna
drwxr-xr-x 2 mike mike 60 Feb 27 15:06 /var/run/minidlna
[root@cubox1 ~]# ls -l /var/run/minidlna
total 4
-rw-r--r-- 1 mike mike 6 Feb 27 15:12 minidlna.pid
')
Now restarting the daemon (after doing systemctl daemon-reload) now gives a correctly started minidlna daemon:
$this->bbcode_second_pass_code('', '
[root@cubox1 ~]# systemctl -l status minidlna
* minidlna.service - minidlna server
Loaded: loaded (/usr/lib/systemd/system/minidlna.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2015-02-27 15:24:59 GMT; 1s ago
Main PID: 15805 (minidlnad)
CGroup: /system.slice/minidlna.service
`-15805 /usr/bin/minidlnad -S
Feb 27 15:24:59 cubox1 systemd[1]: Started minidlna server.
Feb 27 15:24:59 cubox1 minidlnad[15805]: minidlna.c:1026: warn: Starting MiniDLNA version 1.1.4.
Feb 27 15:24:59 cubox1 minidlnad[15805]: minidlna.c:1065: warn: HTTP listening on port 8200
')
Initially when I restarted the daemon with a cleaned out cache area then there were additional messages confirming that the database was being recreated:
$this->bbcode_second_pass_code('', '
Feb 27 15:12:03 cubox1 systemd[1]: Started minidlna server.
Feb 27 15:12:03 cubox1 minidlnad[15782]: minidlna.c:1026: warn: Starting MiniDLNA version 1.1.4.
Feb 27 15:12:03 cubox1 minidlnad[15782]: minidlna.c:355: warn: Creating new database at /var/cache/minidlna/files.db
Feb 27 15:12:03 cubox1 minidlnad[15782]: minidlna.c:1065: warn: HTTP listening on port 8200
Feb 27 15:12:44 cubox1 minidlnad[15782]: playlist.c:125: warn: Parsing playlists...
Feb 27 15:12:44 cubox1 minidlnad[15782]: playlist.c:259: warn: Finished parsing playlists.
')
So finally this is working but there are clearly watchpoints along the way and it is necessary to pay attention to the systemd unit file contents, as well as the contents of the /etc/minidlna.conf file and also the ownership of the pid file directory and the cache directory.
Once all of that is done then it works - apart from so far not having any entries in the log file at /home/mike/.config/minidlna/minidlna.log