dc03f003ac
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABAgAGBQJUa62OAAoJECNuiljG20US1CkP/3YaAg76hJDaeFAyi7/10lOs yI8tPmpQk8S+nuclsBJeIr+9xNRsjb1ebW4tI9uBRxqMT10SF7rMCH/qAmgnS9tQ 6M48hF0o9xegjz4x5BosEJjXtiekYN068Xi/hk+H27guVy14f6Xx7oRpdr5oI/O0 F83D1V2+vs6FuOyn42UQQNHVlYMac5SScHoSFomnwRYWI2wb2ay4H5Dlykb5BUl0 tTjJ2lYwN18vUoMxjmCNS+bLd7jag6FZ/PXntB1zXe22R17eAIuFZAMKaQvnQtUi QZjFPhpd+mBsZLfokB3belyNNb4F6qSG2W6lZrFRB+SU/LqnY2AL/dxPJD9eiufs 5jEIOw9hNBBKo217+hkPwp5pAF50u11tKXUXbKGeR42zAO0zll/+g2afVwoqdAfD llPDyQyXiB3tmA1bgJD7u9gaud3UaaXoxajPb5LnmklzGxiN5u1rnoo+E5ppBvQ4 31wPHGpzsjxEC7Xn9hErPP17jYXY1HT/xRb8XZNrFqJVZxSyjqQlDWomhCWDcvPc Du1PyKaQ08zgElEM5trwC9RjJxQdr0sckQcTnYC/0ksfJ7Nhh8M2yepEI/gmWbnO JBQ7YzpQhE9oMMH8jzVLLdC44yF6QvXcGQ3D9eUfwvPk9Z70mHlNI3Q6kbZ76U5j RHLp+oSaxFUXfPdciZaw =GO+k -----END PGP SIGNATURE----- Merge tag 'v0.18.18' into v0.19.x
65 lines
1.7 KiB
C++
65 lines
1.7 KiB
C++
/*
|
|
* Copyright (C) 2003-2014 The Music Player Daemon Project
|
|
* http://www.musicpd.org
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
#include "Client.hxx"
|
|
#include "protocol/Ack.hxx"
|
|
#include "fs/Path.hxx"
|
|
#include "fs/FileSystem.hxx"
|
|
#include "util/Error.hxx"
|
|
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
|
|
bool
|
|
Client::AllowFile(Path path_fs, Error &error) const
|
|
{
|
|
#ifdef WIN32
|
|
(void)path_fs;
|
|
|
|
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
|
|
return false;
|
|
#else
|
|
if (uid >= 0 && (uid_t)uid == geteuid())
|
|
/* always allow access if user runs his own MPD
|
|
instance */
|
|
return true;
|
|
|
|
if (uid < 0) {
|
|
/* unauthenticated client */
|
|
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
|
|
return false;
|
|
}
|
|
|
|
struct stat st;
|
|
if (!StatFile(path_fs, st)) {
|
|
error.SetErrno();
|
|
return false;
|
|
}
|
|
|
|
if (st.st_uid != (uid_t)uid && (st.st_mode & 0444) != 0444) {
|
|
/* client is not owner */
|
|
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
#endif
|
|
}
|