Skip to content

mpd service: Start when needed and harden #27055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2017

Conversation

jfrankenau
Copy link
Member

Motivation for this change

By using a systemd socket it is possible to start MPD only when it's needed similar to the OpenSSH daemon config option startWhenNeeded.

Additionally, upstream provides a hardened systemd service file which I've integrated here. This also fixes two error messages from MPD regarding real-time priority and Avahi.

Things done

Sorry, something went wrong.

@mention-bot
Copy link

@jfrankenau, thanks for your PR! By analyzing the history of the files in this pull request, we identified @rickynils, @dmalikov and @unaizalakain to be potential reviewers.

listenStreams = [
"/run/mpd/socket"
"${cfg.network.listenAddress}:${toString cfg.network.port}"
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure: Did you test that mpd pick up multiple sockets, when passed via socket activation?

Copy link
Member Author

@jfrankenau jfrankenau Jul 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now and the upstream MPD socket file does the same. I decided to use /var/run/mpd/socket to use the same location MPD uses.

While testing I noticed that any for listenAddress needed to be handled with care in the systemd socket file which is fixed now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more of a general problem, but hardcoding "/run/mpd/socket" here and in other places is a not a modular solution.

It means that if I later want to add another service which is also called mpd, but does something completely different that I need to care about the existence of this particular service; something a well designed system would not require.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I have removed the IPC socket for now. I couldn't find a client where the default is set to a local socket anyway. In the future we could add an option which allows to specify a path for it but I guess most people never even thought about using one.

@jfrankenau jfrankenau force-pushed the mpd-startWhenNeeded branch from 5ed09fa to e4b8633 Compare July 3, 2017 10:09
@jfrankenau jfrankenau force-pushed the mpd-startWhenNeeded branch from e4b8633 to c4528eb Compare July 4, 2017 07:50
@joachifm joachifm merged commit a00a880 into NixOS:master Jul 9, 2017
@jfrankenau jfrankenau deleted the mpd-startWhenNeeded branch July 20, 2017 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants