diff --git a/src/client/Client.hxx b/src/client/Client.hxx index 593709ce6..07e51b969 100644 --- a/src/client/Client.hxx +++ b/src/client/Client.hxx @@ -97,7 +97,9 @@ public: std::list messages; Client(EventLoop &loop, Partition &partition, - UniqueSocketDescriptor fd, int uid, int num) noexcept; + UniqueSocketDescriptor fd, int uid, + unsigned _permission, + int num) noexcept; ~Client() noexcept { if (FullyBufferedSocket::IsDefined()) @@ -239,6 +241,7 @@ client_manager_init(); void client_new(EventLoop &loop, Partition &partition, - UniqueSocketDescriptor fd, SocketAddress address, int uid) noexcept; + UniqueSocketDescriptor fd, SocketAddress address, int uid, + unsigned permission) noexcept; #endif diff --git a/src/client/ClientNew.cxx b/src/client/ClientNew.cxx index 81aa79d79..f29d006aa 100644 --- a/src/client/ClientNew.cxx +++ b/src/client/ClientNew.cxx @@ -42,12 +42,14 @@ static constexpr char GREETING[] = "OK MPD " PROTOCOL_VERSION "\n"; Client::Client(EventLoop &_loop, Partition &_partition, - UniqueSocketDescriptor _fd, int _uid, int _num) noexcept + UniqueSocketDescriptor _fd, + int _uid, unsigned _permission, + int _num) noexcept :FullyBufferedSocket(_fd.Release(), _loop, 16384, client_max_output_buffer_size), timeout_event(_loop, BIND_THIS_METHOD(OnTimeout)), partition(&_partition), - permission(getDefaultPermissions()), + permission(_permission), uid(_uid), num(_num) { @@ -56,7 +58,8 @@ Client::Client(EventLoop &_loop, Partition &_partition, void client_new(EventLoop &loop, Partition &partition, - UniqueSocketDescriptor fd, SocketAddress address, int uid) noexcept + UniqueSocketDescriptor fd, SocketAddress address, int uid, + unsigned permission) noexcept { static unsigned int next_client_num; const auto remote = ToString(address); @@ -93,6 +96,7 @@ client_new(EventLoop &loop, Partition &partition, (void)fd.Write(GREETING, sizeof(GREETING) - 1); Client *client = new Client(loop, partition, std::move(fd), uid, + permission, next_client_num++); client_list.Add(*client); diff --git a/src/client/Listener.cxx b/src/client/Listener.cxx index 4747e4e59..663fd9a7b 100644 --- a/src/client/Listener.cxx +++ b/src/client/Listener.cxx @@ -20,6 +20,7 @@ #include "config.h" #include "Listener.hxx" #include "Client.hxx" +#include "Permission.hxx" #include "net/UniqueSocketDescriptor.hxx" #include "net/SocketAddress.hxx" @@ -28,5 +29,6 @@ ClientListener::OnAccept(UniqueSocketDescriptor fd, SocketAddress address, int uid) noexcept { client_new(GetEventLoop(), partition, - std::move(fd), address, uid); + std::move(fd), address, uid, + getDefaultPermissions()); }