client: pass permission mask to constructor
Prepare for per-listener permissions.
This commit is contained in:
parent
524a7f4560
commit
8aa2c57413
@ -97,7 +97,9 @@ public:
|
||||
std::list<ClientMessage> 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
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user