Help with MPD

Hello
I hadnt used MPD in a while, i went restart it and everything has failed. Permissions, Audo output and the MPD user. I have gone crazy rebuilding MPD on two seperate computers running fedora 40. nothing seems to work, mostly it seems to be permissions error but when I set permissions for the MPD user, it does nothing. I spent several hours trying to get the “mpd” user to work and nothing. I finally switched it to my personal user account and it now works; however, the sound settings with Pipe-wire don’t seem to work. I have tried alsa, pule audio , and pipewire in my mpd.conf files and all tell me that my audio “device” is busy. I have followed every tutorrial i can find. It seemd MPD is next to impossible to set up correctly anymore. If somebody who is a fedora user can help me PLEASE! … below is my mpd.conf file … and under that is the tail from my log file … I realize this is a permissions issue, but I have tried everything and permutation on permissions and selinux settings , nothing works

/etc/mpd.conf

Music directory

music_directory “/home/fausto/Music”

Playlist directory

playlist_directory “/var/lib/mpd/playlists”

MPD database file

db_file “/var/lib/mpd/mpd.db”

Log file

log_file “/var/log/mpd/mpd.log”

MPD PID file

pid_file “/var/run/mpd/mpd.pid”

State file

state_file “/var/lib/mpd/mpdstate”

Sticker file

sticker_file “/var/lib/mpd/sticker.sql”

User and group

user “fausto”
#group “mpd”

Bind to all interfaces

bind_to_address “0.0.0.0”
port “6600”

Input plugin

input {
plugin “curl”
}

Audio output

audio_output {
type “pipewire”
name “PipeWire”
}

#audio_output {

type “alsa”

name “My ALSA Device”

device “” # optional

mixer_type “software” # optional

#io_uring    "no"         # disable io_uring if causing issues

tail /var/log/mpd/mpd.log 12:48:53
Aug 06 12:26 : exception: Failed to open “PipeWire” (pipewire); Failed to connect stream: Host is down
Aug 06 12:26 : exception: Failed to open “PipeWire” (pipewire); Failed to connect stream: Host is down
Aug 06 12:26 : exception: Failed to open “PipeWire” (pipewire); Failed to connect stream: Host is down
Aug 06 12:26 : player: played “Richard Wright - 1978 - Wet Dream (2023 Remix by Steven Wilson) (24bit-96kHz)/01 Mediterranean C.flac”
Aug 06 12:26 : exception: Failed to open “PipeWire” (pipewire); Failed to connect stream: Host is down
Aug 06 12:26 : exception: Failed to open “PipeWire” (pipewire); Failed to connect stream: Host is down
Aug 06 12:26 : player: problems opening audio device while playing “Wynton Kelly & Wes Montgomery - Smokin’ at the Half Note (1965, 1973, Verve-Japan) [LP 24-192]/01 - No Blues.flac”
Aug 06 12:27 : exception: Failed to create /var/lib/mpd/mpdstate: Permission denied
Aug 06 12:32 : exception: Failed to create /var/lib/mpd/mpdstate: Permission denied
Aug 06 12:32 : player: played “Wynton Kelly & Wes Montgomery - Smokin’ at the Half Note (1965, 1973, Verve-Japan) [LP 24-192]/01 - No Blues.flac”

Does it work if you launch it directly from the command line with something like sudo /bin/mpd --no-daemon? (Use Ctrl+C to stop the program when you are done testing it.) If it works when launched as root like that, then try running it as your mpd user with something like sudo -u mpd /bin/mpd --no-daemon. Does it still work when run as the mpd user? If not, are any errors printed to the terminal that might indicate what the problem is?

Edit: It looks like there are also --stderr and --verbose options that can be passed to /bin/mpd to maybe get it to be a little more chatty about what it is having problems with.

Running as MPD user all the erros in the log and the stderr are permissions denied on all the folders associated with mpd. I have gone through and added mpd to groups and changed permissions … nothing worked … now i have it set to run from my user account and it works but I still can’t get audio output to work. when I try to run it as you suggested i get a log permssions error, xception: failed to open log file “/var/log/mpd/mpd.log” (config line 13): Permission denied

mind you, this is on 2 different fedora 40 machines, I have used mpd for years, this is very frustrating… thanks for your help

OK. That was mainly a way to be sure it wasn’t a SELinux permissions issue (when you launch programs from the command line, they run “unconfined” by SELinux). So the permissions issue must be due either to the Unix mode bits, or maybe due to a file lock. Can you access that file with something like sudo -u mpd tail /var/log/mpd/mpd.log? Does lsof /var/log/mpd/mpd.log show that some other process is holding a lock on that log file?

I see that there is an SELinux boolean to allow mpd to access music files stored under a user’s home directory.

$ getsebool mpd_enable_homedirs
mpd_enable_homedirs --> off

Since you have music_directory set to /home/fausto/Music, do you have that boolean enabled?

music_directory "~/Music"
playlist_directory "~/.local/state/mpd"
restore_paused "yes"
zeroconf_enabled "no"

db_file "~/.local/state/mpd/mpd.db"
log_file "/dev/null"
pid_file "/tmp/mpd.pid"
state_file "~/.local/state/mpd/mpdstate"
sticker_file "~/.local/state/mpd/sticker.sql"

audio_output {
    type "fifo"
    name "Visualizer"
    path "/tmp/mpd.fifo"
    format "44100:16:2"
}

audio_output {
    type "pipewire"
    name "PipeWire"
}

The above is my mpd.conf and I start it as a user unit with systemctl --user start mpd.service command and it works fine. Make sure the ~/.local/state/mpd directory (or whatever your choice is) exists.

2 Likes

I think you are right about that boolean… but as my desktop user, it works regarless But i’m still locked out of pipewire, here’s what i get in the log : - ug 06 16:08 : player: problems opening audio device while playing “Wynton Kelly & Wes Montgomery - Smokin’ at the Half Note (1965, 1973, Verve-Japan) [LP 24-192]/01 - No Blues.flac”
Aug 06 16:08 : exception: Failed to open “PipeWire” (pipewire); Failed to connect stream: Host is down

If I’m reading it right, that boolean should allow the mpd daemon to connect to the user’s pipewire socket as well (the last rule in the below output).

$ sesearch --allow -s mpd_t | grep mpd_enable_homedirs
allow mpd_t audio_home_t:dir { getattr ioctl lock open read search }; [ mpd_enable_homedirs ]:True
allow mpd_t audio_home_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t audio_home_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t audio_home_t:file { getattr ioctl lock open read }; [ mpd_enable_homedirs ]:True
allow mpd_t audio_home_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t cifs_t:dir { ioctl lock open read search }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t cifs_t:dir { ioctl lock open read search }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t cifs_t:dir { open search }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t cifs_t:dir { open search }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t cifs_t:file { getattr ioctl lock open read }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t cifs_t:lnk_file { getattr read }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t config_home_t:dir { getattr ioctl lock open read search }; [ mpd_enable_homedirs ]:True
allow mpd_t home_root_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t home_root_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t nfs_t:dir { ioctl lock open read search }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t nfs_t:dir { ioctl lock open read search }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t nfs_t:dir { open search }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t nfs_t:dir { open search }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t nfs_t:file { getattr ioctl lock open read }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t nfs_t:lnk_file { getattr read }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t pulseaudio_home_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t pulseaudio_home_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t pulseaudio_home_t:file { getattr ioctl lock open read }; [ mpd_enable_homedirs ]:True
allow mpd_t pulseaudio_home_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t user_home_dir_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t user_home_dir_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t user_home_dir_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t user_home_dir_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t user_tmp_type:dir { getattr ioctl lock open read search }; [ mpd_enable_homedirs ]:True
allow mpd_t user_tmp_type:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t user_tmp_type:file open; [ mpd_enable_homedirs ]:True
allow mpd_t userdomain:unix_stream_socket connectto; [ mpd_enable_homedirs ]:True

Edit: You might also want to try running sudo restorecon -rv /home/fausto.

what is the command sesearch? I don’t have it … or in fedoras repos ?

Please remind me, exactly what restoreconn -rv does … resets ownership of all the files ?

Thank you
Tim

It looks like the sesearch command is provided by the setools-console package.

$ rpm -qf `which sesearch`
setools-console-4.5.1-2.fc40.x86_64

The restorecon command does not change the file ownership. It only resets the SELinux permissions to their default and correct permissions. It should always be safe to run restorecon unless your system is misconfigured somehow.

ok cool … so i get this:

fausto@fausto-laptop ~ > sesearch --allow -s mpd_t | grep mpd_enable_homedirs 16:53:59
allow mpd_t audio_home_t:dir { getattr ioctl lock open read search }; [ mpd_enable_homedirs ]:True
allow mpd_t audio_home_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t audio_home_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t audio_home_t:file { getattr ioctl lock open read }; [ mpd_enable_homedirs ]:True
allow mpd_t audio_home_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t cifs_t:dir { ioctl lock open read search }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t cifs_t:dir { ioctl lock open read search }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t cifs_t:dir { open search }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t cifs_t:dir { open search }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t cifs_t:file { getattr ioctl lock open read }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t cifs_t:lnk_file { getattr read }; [ use_samba_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t config_home_t:dir { getattr ioctl lock open read search }; [ mpd_enable_homedirs ]:True
allow mpd_t home_root_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t home_root_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t nfs_t:dir { ioctl lock open read search }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t nfs_t:dir { ioctl lock open read search }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t nfs_t:dir { open search }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t nfs_t:dir { open search }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t nfs_t:file { getattr ioctl lock open read }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t nfs_t:lnk_file { getattr read }; [ use_nfs_home_dirs && mpd_enable_homedirs ]:True
allow mpd_t pulseaudio_home_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t pulseaudio_home_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t pulseaudio_home_t:file { getattr ioctl lock open read }; [ mpd_enable_homedirs ]:True
allow mpd_t pulseaudio_home_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t user_home_dir_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t user_home_dir_t:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t user_home_dir_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t user_home_dir_t:lnk_file { getattr read }; [ mpd_enable_homedirs ]:True
allow mpd_t user_tmp_type:dir { getattr ioctl lock open read search }; [ mpd_enable_homedirs ]:True
allow mpd_t user_tmp_type:dir { getattr open search }; [ mpd_enable_homedirs ]:True
allow mpd_t user_tmp_type:file open; [ mpd_enable_homedirs ]:True
allow mpd_t userdomain:unix_stream_socket connectto; [ mpd_enable_homedirs ]:True

I see pukse audio in here, not pipewire … I assumed MPD should be set for pipe-wire … no?

If you enable that boolean, then processes running as mpd_t should be granted access to both pulseaudio and pipewire files. Which ones will actually be used would depend on which service you are running.

as far as i understand the pathway from pipewire to pulse … this test:

speaker-test -c 2 -t wav -l 10

Tells me I’m using pipewire. Correct?

mpd tells me “device busy” when I run it with the pipewire settings. This is honestly a nightmare, i’ve been a pretty serious fedora user for 15 years … this particular mpd problem is aweful .

T

Sorry, I’m not familiar with much of the pipewire stack. If mpd isn’t telling you exactly what file it is trying to access when it fails, I would consider that more of a shortcoming with mpd. “device busy” doesn’t really give any leads as to what it is that is failing. I would try fixing that log file access error and see if you can get further after that.