Skip to content
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

Make Unix sockets writable for user group #56

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,17 @@ The following configuration values are available:

- ``mpd/hostname``:
Which address the MPD server should bind to.
This can be a network address or the path toa Unix socket:
This can be a network address or the path to a Unix socket:

- ``127.0.0.1``: Listens only on the IPv4 loopback interface (default).
- ``::1``: Listens only on the IPv6 loopback interface.
- ``0.0.0.0``: Listens on all IPv4 interfaces.
- ``::``: Listens on all interfaces, both IPv4 and IPv6.
- ``unix:/path/to/unix/socket.sock``: Listen on the Unix socket at the
- ``unix:/var/run/mopidy/mpd.sock``: Listen on the Unix socket at the
specified path. Must be prefixed with ``unix:``.
If `Mopidy is run as a system service <https://docs.mopidy.com/en/latest/running/service/>`_,
users must be added to the ``mopidy`` group (``usermod -a -G mopidy user``)
to communicate with the MPD server over a Unix socket.

- ``mpd/port``:
Which TCP port the MPD server should listen to.
Expand Down
2 changes: 2 additions & 0 deletions mopidy_mpd/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def create_server_socket(self, host, port):
socket_path = get_unix_socket_path(host)
if socket_path is not None: # host is a path so use unix socket
sock = create_unix_socket()
oldmask = os.umask(0o002) # make socket writable for users in the 'mopidy' group
sock.bind(socket_path)
os.umask(oldmask)
very-amused marked this conversation as resolved.
Show resolved Hide resolved
else:
# ensure the port is supplied
if not isinstance(port, int):
Expand Down