View previous topic :: View next topic |
Author |
Message |
ebray187 Tux's lil' helper
Joined: 02 Mar 2005 Posts: 123 Location: Al otro lado de la pantalla
|
Posted: Sun Nov 29, 2020 11:11 pm Post subject: [minidlna] Fix permissions problems to share home media dirs |
|
|
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 |
|
|
ebray187 Tux's lil' helper
Joined: 02 Mar 2005 Posts: 123 Location: Al otro lado de la pantalla
|
Posted: Thu Dec 12, 2024 3:42 pm Post subject: |
|
|
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 |
|
|
FranciscoJaimes n00b
Joined: 15 Jan 2025 Posts: 24 Location: Mexico
|
Posted: Wed Jan 15, 2025 9:54 pm Post subject: |
|
|
To solve the issue with minidlna not starting due to permission problems, follow these steps:
Fix permissions on /run/minidlna:
bash
sudo chown -R <my user>:<my user> /run/minidlna
Create a systemd override to run minidlna as your user:
bash
sudo systemctl edit minidlna
Add the following in the override file:
ini
[Service]
User=<my user>
Group=<my user>
Reload systemd and start the service:
bash
sudo systemctl daemon-reload
sudo systemctl start minidlna
Enable the service at boot:
bash
sudo systemctl enable minidlna
This setup avoids using root and ensures minidlna runs with the correct user permissions. |
|
Back to top |
|
|
ebray187 Tux's lil' helper
Joined: 02 Mar 2005 Posts: 123 Location: Al otro lado de la pantalla
|
Posted: Thu Jan 16, 2025 12:27 am Post subject: |
|
|
FranciscoJaimes wrote: | To solve the issue with minidlna not starting due to permission problems, follow these steps:
Fix permissions on /run/minidlna:
bash
sudo chown -R <my user>:<my user> /run/minidlna
Create a systemd override to run minidlna as your user:
bash
sudo systemctl edit minidlna
Add the following in the override file:
ini
[Service]
User=<my user>
Group=<my user>
Reload systemd and start the service:
bash
sudo systemctl daemon-reload
sudo systemctl start minidlna
Enable the service at boot:
bash
sudo systemctl enable minidlna
This setup avoids using root and ensures minidlna runs with the correct user permissions. |
That's already in the original solution. However, in the latest versions, the permissions were overwritten on each system boot, so I added the additional instructions.
I don't understand your post. Is there any difference with the solution provided years ago? _________________ # emerge -C world >> 9/8
A flower?! |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 23017
|
Posted: Thu Jan 16, 2025 1:06 am Post subject: |
|
|
ebray187 wrote: | That's already in the original solution. However, in the latest versions, the permissions were overwritten on each system boot, so I added the additional instructions.
I don't understand your post. Is there any difference with the solution provided years ago? | FranciscoJaimes is a newly registered user who posted a large number of such posts in short order, possibly as a spam precursor. Based on the post structure, I suspect these were generated via ChatGPT or similar. |
|
Back to top |
|
|
|