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
726fc53e
Commit
726fc53e
authored
Oct 27, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client: add AllowFile() overload which throws exception
parent
c598686b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
Client.hxx
src/client/Client.hxx
+4
-1
ClientFile.cxx
src/client/ClientFile.cxx
+25
-0
No files found.
src/client/Client.hxx
View file @
726fc53e
...
...
@@ -176,9 +176,12 @@ public:
* We cannot fix this as long as there are plugins that open a file by
* its name, and not by file descriptor / callbacks.
*
* Throws #std::runtime_error on error.
*
* @param path_fs the absolute path name in filesystem encoding
* @return true if access is allowed
*/
void
AllowFile
(
Path
path_fs
)
const
;
bool
AllowFile
(
Path
path_fs
,
Error
&
error
)
const
;
/**
...
...
src/client/ClientFile.cxx
View file @
726fc53e
...
...
@@ -26,6 +26,31 @@
#include <unistd.h>
void
Client
::
AllowFile
(
Path
path_fs
)
const
{
#ifdef WIN32
(
void
)
path_fs
;
throw
ProtocolError
(
ACK_ERROR_PERMISSION
,
"Access denied"
);
#else
if
(
uid
>=
0
&&
(
uid_t
)
uid
==
geteuid
())
/* always allow access if user runs his own MPD
instance */
return
;
if
(
uid
<
0
)
/* unauthenticated client */
throw
ProtocolError
(
ACK_ERROR_PERMISSION
,
"Access denied"
);
const
FileInfo
fi
(
path_fs
);
if
(
fi
.
GetUid
()
!=
(
uid_t
)
uid
&&
(
fi
.
GetMode
()
&
0444
)
!=
0444
)
/* client is not owner */
throw
ProtocolError
(
ACK_ERROR_PERMISSION
,
"Access denied"
);
#endif
}
bool
Client
::
AllowFile
(
Path
path_fs
,
Error
&
error
)
const
{
...
...
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