Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
8aa2c574
Commit
8aa2c574
authored
Jul 13, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: pass permission mask to constructor
Prepare for per-listener permissions.
parent
524a7f45
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
+15
-6
Client.hxx
src/client/Client.hxx
+5
-2
ClientNew.cxx
src/client/ClientNew.cxx
+7
-3
Listener.cxx
src/client/Listener.cxx
+3
-1
No files found.
src/client/Client.hxx
View file @
8aa2c574
...
...
@@ -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
src/client/ClientNew.cxx
View file @
8aa2c574
...
...
@@ -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
);
...
...
src/client/Listener.cxx
View file @
8aa2c574
...
...
@@ -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
());
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment