weird problem with file permissions

Need help with MPD?
Post Reply
knarf
Posts: 4
Joined: October 3rd, 2017, 12:50 pm

weird problem with file permissions

Post by knarf » October 3rd, 2017, 1:20 pm

Hello,

I'm using mpd 0.20.9 with opensuse 42.3.
Mpd is configured to run as user 'mpd' with group 'audio'.

My problem is that mpd often is unable to start because the permissions of the files 'mpd.db' and 'mpdstate' are set to 000 every time these files have been updated.

The files are stored in /home/mpd/.mpd/ with the following permissions

Code: Select all

drwxr-xr-x 2 mpd  audio   4096  3. Okt 15:04 .mpd/
After a restart of the machine the file permissions look like this (take notice of the file mpdstate)

Code: Select all

drwxr-xr-x 2 mpd audio   4096  3. Okt 15:11 ./
drwxr-xr-x 9 mpd audio   4096  3. Okt 14:05 ../
-rw-rw-r-- 1 mpd audio 292500 29. Sep 17:48 mpd.db
---------- 1 mpd audio   1478  3. Okt 15:11 mpdstate
After adding new music to my music directory, the same happens to file mpd.db.

I then have to manually restore the file permissions back to rw-rw-r-- in order to make mpd work again.

What is going on here? Any help is appreciated.

greetings knarf
Last edited by knarf on October 5th, 2017, 9:13 am, edited 1 time in total.

max
Forum team
Posts: 619
Joined: January 15th, 2013, 3:43 pm

Re: weird problem with file permissions

Post by max » October 3rd, 2017, 8:18 pm

Then MPD's umask is fishy. How do you launch MPD?

knarf
Posts: 4
Joined: October 3rd, 2017, 12:50 pm

Re: weird problem with file permissions

Post by knarf » October 5th, 2017, 9:12 am

Hello and thank You for your reply.

Mpd is started as a service by systemd.

cat /usr/lib/systemd/system/mpd.service

Code: Select all

[Unit]
Description=Music Player Daemon
Documentation=man:mpd(1) man:mpd.conf(5)
After=network.target sound.target

[Service]
Type=notify
ExecStart=/usr/bin/mpd --no-daemon

# allow MPD to use real-time priority 50
LimitRTPRIO=50
LimitRTTIME=infinity

# disallow writing to /usr, /bin, /sbin, ...
ProtectSystem=yes

# more paranoid security settings
NoNewPrivileges=yes
ProtectKernelTunables=yes
ProtectControlGroups=yes
ProtectKernelModules=yes
# AF_NETLINK is required by libsmbclient, or it will exit() .. *sigh*
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK
RestrictNamespaces=yes

[Install]
WantedBy=multi-user.target
Also=mpd.socket
I hope this helps

max
Forum team
Posts: 619
Joined: January 15th, 2013, 3:43 pm

Re: weird problem with file permissions

Post by max » October 5th, 2017, 12:48 pm

Post the output of the following two commands:

Code: Select all

grep ^Umask /proc/`pidof mpd`/status
systemctl show mpd|grep ^UMask=

knarf
Posts: 4
Joined: October 3rd, 2017, 12:50 pm

Re: weird problem with file permissions

Post by knarf » October 5th, 2017, 9:07 pm

Here it is

grep ^Umask /proc/`pidof mpd`/status

The files 'status' exists but no UMask in it.


systemctl show mpd|grep ^UMask=

Code: Select all

UMask=0022
Seems to be ok, isn't it?
I tried to create a testfile via touch in mpd's working dir as user mpd, and the permissions where rw-r--r--.

max
Forum team
Posts: 619
Joined: January 15th, 2013, 3:43 pm

Re: weird problem with file permissions

Post by max » October 6th, 2017, 7:39 am

Strange, which kernel version do you have? My 4.13 kernel does have this status line, and an older machine with 4.9 has it as well. Maybe your kernel is even older.

The systemd umask is ok. MPD has no code to change the umask, and it passes mode=0666 for creating new files, which should result in 0644 after your umask got applied.

It seems impossible that this is caused by MPD, at least I cannot imagine how. Maybe some other program/script changes the file modes, but I have no idea why anybody would do that.

When you stop MPD, it should write the state file. Does the new state file immediately after stopping already have this mode?

knarf
Posts: 4
Joined: October 3rd, 2017, 12:50 pm

Re: weird problem with file permissions

Post by knarf » October 6th, 2017, 11:06 pm

Hi,

my kernel is:

uname -r

Code: Select all

4.4.87-25-default
When you stop MPD, it should write the state file. Does the new state file immediately after stopping already have this mode?
Yes stopping MPD immediately breaks the file permissions.

What puzzles me is that nobody else on the net seems to have a similar problem.

I changed the umask for user mpd, in order to see if it makes any difference. It does if I create a file as user mpd, but not for files updated by MPD.

Any more ideas?

Post Reply