Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[minidlna] Fix permissions problems to share home media dirs
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
ebray187
Tux's lil' helper
Tux's lil' helper


Joined: 02 Mar 2005
Posts: 122
Location: Al otro lado de la pantalla

PostPosted: Sun Nov 29, 2020 11:11 pm    Post subject: [minidlna] Fix permissions problems to share home media dirs Reply with quote

This light and excellent program meets all the needs of my home DLNA server, the problem is that every time it is updated rewrites the files and the systemd service does not get up unless I change the permissions inside my home folder or use root (which I definitely don't want). With this post I intend to help those who have a similar problems tried with minidlna and to use it myself for future references.

The problem:

After emerging, changing the user in /etc/minidlna.conf so i can share my multimedia files from my home folder:
Code:
user=<my user>
media_dir=A,/home/<myuser>/Music
media_dir=V,/home/<myuser>/Movies
db_dir=/home/<myuser>/.cache/minidlna
log_dir=/home/<myuser>/.local/share/minidlna
Code:
$ mkdir ~/.cache/minidlna ~/.local/share/minidlna

<my user> is in the minidlna group:
Code:
# usermod -a -G minidlna <my user>
but anyway # systemctl start minidlna return this error:
Code:
minidlna.c:482: error: Unable to open pidfile for writing /run/minidlna/minidlna.pid: Permission denied
minidlna.c:1070: fatal: Failed to switch to gid '<gid>'. [Operation not permitted]

Or this one on a new system # systemclt status minidlna:
Code:
utils.c:295: make_dir: cannot create directory '/home/<my user>/.cache/minidlna'
minidlna.c:714: fatal: Database path not accessible!

I don't want to use root nor give minidlna group permissions for my home folder.

The solution:

The minidlna.pid problem its straight foward: Give permissions to <my user>:
Code:
chown -R <my user>:<my user> /run/minidlna

The second problem is also straight foward (after spending 1 and a half hour reviewing logs, source code and reading some linux and systemd permission notes :? )
So, we are going to make a override file for the systemd unit file (minidlna.service)
Code:
# systemctl edit minidlna

And add this:
Code:
[Service]
User=<my user>
Group=<my user>

Done

Reload and start the service

Now everything should work:
Code:
# systemctl daemon-reload
# systemctl start minidlna

Code:
# systemctl status minidlna
● minidlna.service - MiniDLNA server
     Loaded: loaded (/lib/systemd/system/minidlna.service; enabled; vendor preset: disabled)
    Drop-In: /etc/systemd/system/minidlna.service.d
             └─override.conf
     Active: active (running) since Sun 2020-11-29 19:35:03 -03; 3s ago
   Main PID: 39124 (minidlnad)
        CPU: 27ms
     CGroup: /system.slice/minidlna.service
             └─39124 /usr/sbin/minidlnad -f /etc/minidlna.conf -P /run/minidlna/minidlna.pid -S

Great!
Code:
# systemctl enable minidlna

_________________
# emerge -C world >> 9/8
A flower?!
Back to top
View user's profile Send private message
ebray187
Tux's lil' helper
Tux's lil' helper


Joined: 02 Mar 2005
Posts: 122
Location: Al otro lado de la pantalla

PostPosted: Thu Dec 12, 2024 3:42 pm    Post subject: Reply with quote

This solution was working fine some years, but in recent updates I have to manually change the permissions at each system boot. So, maybe this further steps are also needed in your system:

1. Create a new /etc/tmpfiles.d/minidlna.conf config file with this content:

Code:
d /run/minidlna 0755 <my_user> <my_user> -


That should properly handle the permissions.

2. This fixes a issue where sometimes the server is not displayed in the client devices (cause systemd is loading the service before the network interface is fully available):

Code:
# systemctl edit minidlna


Code:
[Unit]
After=multi-user.target

_________________
# emerge -C world >> 9/8
A flower?!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum