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
c2d5ce0c
Commit
c2d5ce0c
authored
Oct 19, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client: move trivial functions into the Client class
parent
32645b80
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
50 deletions
+31
-50
AllCommands.cxx
src/AllCommands.cxx
+3
-3
Client.cxx
src/Client.cxx
+0
-18
Client.hxx
src/Client.hxx
+24
-25
ClientFile.cxx
src/ClientFile.cxx
+1
-1
OtherCommands.cxx
src/OtherCommands.cxx
+3
-3
No files found.
src/AllCommands.cxx
View file @
c2d5ce0c
...
...
@@ -182,7 +182,7 @@ static enum command_return
handle_commands
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
const
unsigned
permission
=
client
_get_permission
(
client
);
const
unsigned
permission
=
client
.
GetPermission
(
);
const
struct
command
*
cmd
;
for
(
unsigned
i
=
0
;
i
<
num_commands
;
++
i
)
{
...
...
@@ -200,7 +200,7 @@ static enum command_return
handle_not_commands
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
const
unsigned
permission
=
client
_get_permission
(
client
);
const
unsigned
permission
=
client
.
GetPermission
(
);
const
struct
command
*
cmd
;
for
(
unsigned
i
=
0
;
i
<
num_commands
;
++
i
)
{
...
...
@@ -364,7 +364,7 @@ command_process(Client &client, unsigned num, char *line)
/* look up and invoke the command handler */
cmd
=
command_checked_lookup
(
client
,
client
_get_permission
(
client
),
cmd
=
command_checked_lookup
(
client
,
client
.
GetPermission
(
),
argc
,
argv
);
if
(
cmd
)
ret
=
cmd
->
handler
(
client
,
argc
,
argv
);
...
...
src/Client.cxx
View file @
c2d5ce0c
...
...
@@ -22,21 +22,3 @@
#include "util/Domain.hxx"
const
Domain
client_domain
(
"client"
);
int
client_get_uid
(
const
Client
&
client
)
{
return
client
.
uid
;
}
unsigned
client_get_permission
(
const
Client
&
client
)
{
return
client
.
permission
;
}
void
client_set_permission
(
Client
&
client
,
unsigned
permission
)
{
client
.
permission
=
permission
;
}
src/Client.hxx
View file @
c2d5ce0c
...
...
@@ -102,6 +102,30 @@ public:
using
FullyBufferedSocket
::
Write
;
/**
* returns the uid of the client process, or a negative value
* if the uid is unknown
*/
int
GetUID
()
const
{
return
uid
;
}
/**
* Is this client running on the same machine, connected with
* a local (UNIX domain) socket?
*/
bool
IsLocal
()
const
{
return
uid
>
0
;
}
unsigned
GetPermission
()
const
{
return
permission
;
}
void
SetPermission
(
unsigned
_permission
)
{
permission
=
_permission
;
}
/**
* Send "idle" response to this client.
*/
void
IdleNotify
();
...
...
@@ -125,31 +149,6 @@ client_new(EventLoop &loop, Partition &partition,
int
fd
,
const
struct
sockaddr
*
sa
,
size_t
sa_length
,
int
uid
);
/**
* returns the uid of the client process, or a negative value if the
* uid is unknown
*/
gcc_pure
int
client_get_uid
(
const
Client
&
client
);
/**
* Is this client running on the same machine, connected with a local
* (UNIX domain) socket?
*/
gcc_pure
static
inline
bool
client_is_local
(
const
Client
&
client
)
{
return
client_get_uid
(
client
)
>
0
;
}
gcc_pure
unsigned
client_get_permission
(
const
Client
&
client
);
void
client_set_permission
(
Client
&
client
,
unsigned
permission
);
/**
* Write a C string to the client.
*/
void
client_puts
(
Client
&
client
,
const
char
*
s
);
...
...
src/ClientFile.cxx
View file @
c2d5ce0c
...
...
@@ -41,7 +41,7 @@ client_allow_file(const Client &client, Path path_fs, Error &error)
error
.
Set
(
ack_domain
,
ACK_ERROR_PERMISSION
,
"Access denied"
);
return
false
;
#else
const
int
uid
=
client
_get_uid
(
client
);
const
int
uid
=
client
.
GetUID
(
);
if
(
uid
>=
0
&&
(
uid_t
)
uid
==
geteuid
())
/* always allow access if user runs his own MPD
instance */
...
...
src/OtherCommands.cxx
View file @
c2d5ce0c
...
...
@@ -67,7 +67,7 @@ enum command_return
handle_urlhandlers
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
if
(
client
_is_local
(
client
))
if
(
client
.
IsLocal
(
))
client_puts
(
client
,
"handler: file://
\n
"
);
print_supported_uri_schemes
(
client
);
return
COMMAND_RETURN_OK
;
...
...
@@ -262,7 +262,7 @@ handle_password(Client &client, gcc_unused int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
}
client
_set_permission
(
client
,
permission
);
client
.
SetPermission
(
permission
);
return
COMMAND_RETURN_OK
;
}
...
...
@@ -271,7 +271,7 @@ enum command_return
handle_config
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
if
(
!
client
_is_local
(
client
))
{
if
(
!
client
.
IsLocal
(
))
{
command_error
(
client
,
ACK_ERROR_PERMISSION
,
"Command only permitted to local clients"
);
return
COMMAND_RETURN_ERROR
;
...
...
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